Which is the Best Java Web Framework ?

Java - Interview Questions and Answers on Access Specifiers

Q1.  Difference between Public, Private, Default and Protected ?

Ans. 

Private - Not accessible outside object scope. 
Public - Accessible from anywhere. 
Default - Accessible from anywhere within same package.
Protected - Accessible from object and the sub class objects.

Q2.  Can we reduce the visibility of the overridden method ?

Ans. No

Q3.  Which access specifier can be used with Class ?

Ans. For top level class we can only use "public" and "default". We can use private with inner class.

Q4.  Can we reduce the visibility of the inherited or overridden method ?

Ans. No.

Q5.  What will happen if we make the constructor private ?

Ans. We can't create the objects directly by invoking new operator.

Q6.  Can we instantiate the object of derived class if parent constructor is protected ?

Ans. No

Q7.  Can we declare an abstract method private ?

Ans. No Abstract methods can only be declared protected or public.
Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus




×

Try our new Java Interview Questions Search Tool.

There are more than 1000 questions with practice tests.

It's updated daily and It's Awesome.


×

Try our new Java Practice Test tool.

There are more than 200 questions and expanding quickly. It's updated daily and It's Awesome.