IntelliJ Java IDE
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner class declared Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Inner class declared " Watch "Inner class declared " New topic
Author

Inner class declared

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Which of the following statements are true regarding Inner
Q1
classes or class where they are declared and instantiated.
new SimpleInterface(){} ans : true
new ComplexInterface(){} ans :true
Myclass extends Object {} ans : true
new Myclass extends Object {} ans: false
abstrct class inner ans: true
private class C ans: true
new MyInterface(x) {} ans: false
am i correct??
Q2
1. inner class can be instantiated only in it's enclosing class ans:false
2. they can be accessed only within the enclosing class ans:false
3. they cannot implement interface ans: false
4. they can access final varaibles and final methods within their declaration
scope ans:true
5. Top level nested clas need not be instantiated: true
am i right.pls explan?
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
Hi Ken,
In ur first ques. u got it all right except

Myclass extends Object {} : ans is false
because the word class is missing.
the correct declaration should have been
class Myclass extends Object {}


as far as secon ques goes for the first 4 options I agree with u.
but option 5) i cud not get what does it mean?
regards
deekasha
 
 
subject: Inner class declared
 
Threads others viewed
Innerclass Qn
Inner Class
Help me
about anonymous inner class
Inner Class
developer file tools