|
INTERVIEW QUESTIONS
J2EE
CORE JAVA
DETAILS
Question: What are Access Specifiers available in Java?
Answer: Java offers four access specifiers, listed below in decreasing accessibility:
* Public- public classes, methods, and fields can be accessed from everywhere. * Protected- protected methods and fields can only be accessed within the same class to which the methods and fields belong, within its subclasses, and within classes of the same package. * Default(no specifier)- If you do not set access to specific level, then such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs, but not from outside this package. * Private- private methods and fields can only be accessed within the same class to which the methods and fields belong. private methods and fields are not visible within subclasses and are not inherited by subclasses.
|
|
|
Category |
Core Java Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9244 users |
Added on |
9/23/2014 |
Views |
72193 |
Rate it! |
|
|
Question:
What are Access Specifiers available in Java?
Answer:
Java offers four access specifiers, listed below in decreasing accessibility:
* Public- public classes, methods, and fields can be accessed from everywhere. * Protected- protected methods and fields can only be accessed within the same class to which the methods and fields belong, within its subclasses, and within classes of the same package. * Default(no specifier)- If you do not set access to specific level, then such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs, but not from outside this package. * Private- private methods and fields can only be accessed within the same class to which the methods and fields belong. private methods and fields are not visible within subclasses and are not inherited by subclasses. 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 are Access Specifiers?
|
View Answer
|
|
How are this() and super() used with constructors?
|
View Answer
|
|
What are the differences between Class Methods and Instance Methods?
|
View Answer
|
|
How are this() and super() used with constructors?
|
View Answer
|
|
What are the differences between Contructors and Methods?
|
View Answer
|
|
Can constructor be inherited?
|
View Answer
|
|
How does the Java default constructor be provided?
|
View Answer
|
|
What is Constructor?
|
View Answer
|
|
Can there be an abstract class with no abstract methods in it?
|
View Answer
|
|
When you declare a method as abstract, can other nonabstract methods access it?
|
View Answer
|
|
When should I use abstract classes and when should I use interfaces?
|
View Answer
|
|
What are the differences between Interface and Abstract class?
|
View Answer
|
|
Can we instantiate an abstract class?
|
View Answer
|
|
What is an abstract class?
|
View Answer
|
|
What is a marker interface?
|
View Answer
|
|
What modifiers are allowed for methods in an Interface?
|
View Answer
|
|
Do interfaces have member variables?
|
View Answer
|
|
Can we create an object for an interface?
|
View Answer
|
|
Can we instantiate an interface?
|
View Answer
|
|
What is an Interface?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Core Java Interview Questions & Answers - Exam Mode /
Learning Mode
|