© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Classes, Objects and Access Specifiers ▼

Java Interview Questions On Classes, Objects and Access Specifiers

1. Explain More about classes?

Answer

  • l A class is usually described as the template or blueprint from which the object is actually made.
  • l A class is nothing but new data type
  • l Keyword class is used to create new classes (data types)
  • l Keyword extends is used to inherit the features of another class
  • l Any class declared, automatically extends java.lang.Object classes, "The Mother of all classes"

2. Explain About java methods?

Answer

  • A method in Java is similar to function in C/C++ or any other language
  • A method is declared inside a class and belongs to the same class
  • A method can be called using . operator.

3. Explain About java member (instance) variables?

Answer:

  • l Accessible from any method in the class.
  • l Scope of the member variables is the entire class scope.
  • l If there is no explicit initialization, then the value depends upon the data type of the member variable.

4. What are the technical behavior of the java automatic variables?

Answer:

  • Also known as local variables generally declared inside the methods.
  • Scope of the automatic variable is the scope of the method.
  • Automatic variables are not initialized by the compiler.
  • All the variables defined in a method scope must be initialized explicitly before being used.

5. What about java access modifiers?

Answer:
Java has access specifiers are public, private, protected. These can be placed infront of each definition for each member in your class, whether it's a data member or a method. Each access specifier controls the access for only that particular definition. This is a distinct contrast to C++, in which the access specifier controls all the definitions following it until another access specifier comes along.

Java access Modifiers.

  • l public
  • l private
  • l protected

Note: These controls access to a class, a method, and member variable or an instance variable.

Next
1 2 3 4 5 6 7 8
SLogix Student Projects
bottom