ALLInterview.com :: Home Page KalAajKal.com
 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  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 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
How to access a variable if it is declared as private?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to access a variable if it is declared as private?
Answer
# 1
If a variable inside a class is marked private then it
cannot be accessed directly.

Access to this variable can only be provided by a public
accessor and mutator methods. Example:

class MyClass {
    private int dataValue;
    
    public int getDataValue {
        return dataValue;
    }

    public void setDataValue( int newValue ) {
        dataValue = newValue;
    }
}
 
Is This Answer Correct ?    6 Yes 2 No
Ranganathkini
 
  Re: How to access a variable if it is declared as private?
Answer
# 2
the variable declared as private can be accessed with in the
same class only
 
Is This Answer Correct ?    1 Yes 1 No
Ravikiran(aptech Mumbai)
 
 
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is Distributed Application and what is its usage?  1
What method is used to know the status of Checkbox(i.e it is checked or unchecked)?  1
How the elements are organized in GridBagLayout?  1
How are this() and super() used with constructors?  4
What is meant by throwing an Exception? Accenture4
If there is no implementation of MARKER INTERFACE in java. Then how compiler come to know about specification.  2
Write program to print Hello World and print each character address in that string and print how many times each character is in that string? Ex: H: 0 & 1 e:1 & 1 l :2,3,8 & 3 o:4,6 & 2 w:5 & 1 r: 7 & 1 d 9 & 1 Huawei3
watz the difference between abstract class and interface? Which one u ill choose as a designer? Sonata1
how to connect one jsp page to another jsp page???? Symphony4
Difference String and String Buffer  3
How Array List can be Serialized. Polaris5
os is developed in c no java is more secured then c na why dont the os developed is developed using java  1
how many types of cloning? Mobily1
What is UNICODE?  3
What is a J2EE component? List out all the component? Adobe2
What is an Exception ?  6
question on Thread synchronization Huawei1
what is finalmethod & final variable with example? HP2
can we declare private class in java file?  6
Difference between the paint() and repaint() methods?  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 © 2007  ALLInterview.com.  All Rights Reserved.

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