|
INTERVIEW QUESTIONS
J2EE
JAVA
DETAILS
Question: What are the various access specifiers for Java classes?
Answer: 1. Public : Class,Method,Field is accessible from anywhere.
2. Protected:Method,Field can be accessed from the same class to which they belong or from the sub-classes,and from the class of same package,but not from outside.
3. Default: Method,Field,class can be accessed only from the same package and not from outside of it’s native package.
4. Private: Method,Field can be accessed from the same class to which they belong.
|
|
|
Category |
Java Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 6965 users |
Added on |
5/2/2016 |
Views |
69592 |
Rate it! |
|
|
Question:
What are the various access specifiers for Java classes?
Answer:
1. Public : Class,Method,Field is accessible from anywhere.
2. Protected:Method,Field can be accessed from the same class to which they belong or from the sub-classes,and from the class of same package,but not from outside.
3. Default: Method,Field,class can be accessed only from the same package and not from outside of it’s native package.
4. Private: Method,Field can be accessed from the same class to which they belong. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is the difference between an Inner Class and a Sub-Class?
|
View Answer
|
|
can we write main method without static keyword in java main class, give an example
|
View Answer
|
|
Can we create object of Object class in java?
|
View Answer
|
|
what is the difference between java and c++
|
View Answer
|
|
Give me the example of how in real life example Thread is used...
|
View Answer
|
|
How should I start learning Advanced Java? Which books to refer ???
|
View Answer
|
|
Why should we use java?
|
View Answer
|
|
java does not support multiple inheritance because different classes may have different variable with same name that may be contradicted and can cause confusions resulting in errors.Java supports it through the interfaces.A class can extend one class and can implement more than one interfaces also.those interfaces may have variables with same names.Wont they create confusion?
|
View Answer
|
|
static functions can call only other static functions and static variables then how does public static void main(String args[]) function is successful to call non-static functions and also non static variables?
|
View Answer
|
|
we have been taught that whenever an object is created it always invokes a constructor, if not defined in the class then the compiler implicitly invokes it. why??? if there is a parameterized constructor in the class then the compiler does not provide the default constructor why?????
|
View Answer
|
|
can there be an abstact class with no abstact methods in it?
|
View Answer
|
|
What is JDBC API in JAVA?
|
View Answer
|
|
Why the multiple inheritance is not possible in java and if possible HOW??
|
View Answer
|
|
Why we use interface in java?
|
View Answer
|
|
Give a sample program in Java?
|
View Answer
|
|
Does java support Line by Line execution?
|
View Answer
|
|
What are the main features of java and c++?
|
View Answer
|
|
I have one java action form that i setAttribut() and on jsp get reslutset as getAttribute() and print on jsp. again i want this rsult on next jsp threw getAttribute(), but on this last page i cannot get result. so how to do this. i have tried this to setAttribute() and again get but it gets only reference on last page so please give me solution.
|
View Answer
|
|
How many modifiers are there in java?
|
View Answer
|
|
What is the difference between interface and abstract class ?
|
View Answer
|