© 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

6. Define public?

Answer
public is a Access Modifier.

"AVAILABLE TO WORLD"

  • Available to everyone, everywhere
  • You cannot have more than one public class in a single .java file

Given to:

  • Class itself
  • Methods
  • Member Variables
  • Inner classes

7. Explain about private?

Answer

The 'private' is a Access Modifier. THIS IS A LEAST ACCESS MODIFIER.

Given to

  • Methods
  • Variables
  • Inner classes

If a member variable is defined as private, available to all methods of the class scope. You cannot assign it to top level classes ( except for inner classes). A child class cannot access private features of parent class.

8. What about protected modifier?

Answer:

THE MODIFIER 'PROTECTED' A BIT OF MISLEADING.

Given to:
l Methods
l Variables
l Inner classes.

Notes:

  • l Protected features are available to all the classes and subclasses within a package.
  • Available to only subclasses in a different package
Next
1 2 3 4 5 6 7 8
SLogix Student Projects
bottom