ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
   
 
Categories  >>  Software  >>  Java Related  >>  Java J2EE  >>  Core Java
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Real Time sample code for Encapsulation and Abstraction.
where to use abstract  and where to use specifies like
public private.
 Question Submitted By :: Rajendra007
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use specifies like public private.
Answer
# 1
Encapsulation & Abstraction:

The private variable declaration is abstration,and making
usage of getters and setters is encapsulation

private String name="";
private String school="";

public String getName()
{
return name;
}

public void setName(String name)
{
this.name=name;
}

When We use private when we want to restrict the access
within the class.

When we use public then the variable or method will be
accessible in all the locations
 
Is This Answer Correct ?    18 Yes 1 No
Ravikiran
 
  Re: Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use specifies like public private.
Answer
# 2
Encapsulation is used when v need to use a data with the
object access.
Abstraction is used when v need to restrict the end user to
access all process.
 
Is This Answer Correct ?    1 Yes 10 No
Manikandan [ Gtec,vellore ]
 
 
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Is it possible to write JAVA program without including any of the packages,such as "import java.io.*"; bcoz I instantly wrote a code without "import..." statement and runned the program on command Line & it worked. the code is: class Person { String name; int age; Person(String s,int a) { name = s; age = a; } accept() { System.out.println(name+"Hi!!!!!"); System.out.println(age); } } class Demo { public static void main(Strings args[])throws IOException { String name = args[0]; int age = Integer.parseInt(args[1]); Person p = new Person(name,age); p.accept(); } }  3
what should do when using multiple catch() block & what should never do for the same?  1
what is difference between signed & unsigned char?  2
How 'java' got its name and what it stands for? Wipro10
what is the purpose of method overriding in java where v r completely re-defining a inherited method instead y can't v create a new method and define.If the question is very silly plz excuse me and do reply.Thank U! emc27
What are inner and anonymous class?  2
String is an immutable object. Then how can the following code be justified. String s1 = ?ABC?; String s1 = s1+?XYZ?; s.o.p(s1); The output is ABCXYZ, which is the value of s1 ? Flextronics6
hoe can u call a constructor of a private classs to other inherited claa??  1
class A { private int i; } class B extends A { private int i; } if I create an object of B class what will be the memory of that object. Yamaha2
what are the uses of Class class and what it returns? explain it with the example code.  1
What are wrapper classes? Noah-Solutions11
What is run-time class and system class? what is their purpose?  1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com