Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Core Java - Interview Questions and Answers for 'Static nested classe' - 3 question(s) found - Order By Rating | ||||
| ||||
Ans. The accessibility (public, protected, etc.) of the static nested class is defined by the outer class. A static nested class is not an inner class, it's a top-level nested class. The name of the static nested class is expressed with OuterClassName.NestedClassName syntax. When you define an inner nested class (or interface) inside an interface, the nested class is declared implicitly public and static. Static nested classes can be declared abstract or final. Static nested classes can extend another class or it can be used as a base class. Static nested classes can have static members. Static nested classes can access the members of the outer class (only static members, obviously). The outer class can also access the members (even private members) of the nested class through an object of nested class. If you don't declare an instance of the nested class, the outer class cannot access nested class elements directly. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   oops   nested classes   static nested classes   inner classes | ||||
Related Questions | ||||
Which of the following can be marked static ? a. Methods , Variables and Initialization Blocks. b. Methods , Variables , Initialization Blocks and Outer Classes and nested Classes. c. Methods , Variables , Initialization Blocks and Outer Classes. d. Methods , Variables , Initialization Blocks and nested Classes | ||||
Which of the following cannot be marked static ? | ||||
| ||||
Ans. Methods , Variables , Initialization Blocks and nested Classes | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  oops   java   static   nested classes   static nested classes | ||||
Try 2 Question(s) Test | ||||
Related Questions | ||||
What do you mean by "Java is a statically typed language" ? | ||||
How can we run a java program without making any object? | ||||
Which of the following combination of keywords is illegal in Java ? a. static and transient b. transient and final c. static and synchronized d. abstract and final | ||||
What are the advantages and disadvantages of static variables and static methods ? | ||||
What are concepts introduced with Java 5 ? | ||||
Why do we write public static void main ? Can we use some other syntax too for main ? | ||||
Difference between Static and Singleton Class ? | ||||
Can we declare static variables as transient ? | ||||
Which of the following is false about main method ? a. It should be declared public and static b. it should have only 1 argument of type String array c. We can override main method d. We can overload main method | ||||
Ans. Constructors , Classes ( Outer ) , Interfaces , Local variables , Inner Class methods and instance variables. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  oops   java   static   nested classes   static nested classes | ||||
Try 2 Question(s) Test | ||||
Related Questions | ||||
Which of the following can be marked static ? a. Methods , Variables and Initialization Blocks. b. Methods , Variables , Initialization Blocks and Outer Classes and nested Classes. c. Methods , Variables , Initialization Blocks and Outer Classes. d. Methods , Variables , Initialization Blocks and nested Classes | ||||
What is the difference between inner class and sub class ? | ||||
Difference between nested and inner classes ? | ||||
What is a nested interface ? | ||||
What is the benefit of inner / nested classes ? | ||||
Explain Static nested Classes ? | ||||
Can we have an inner class within Interface ? | ||||
Upon compiling the following class, What .class files will get created public class OuterClass{ class InnerClass{ } } | ||||
Can we declare a class private ? | ||||