Ase Lindskog

Greenhorn
+ Follow
since Apr 08, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ase Lindskog

Originally posted by Clement Ng:
Hi,
Order of code execution
1.static variables initialization.
2.static initializer block execution. (in the order of declaration, if multiple blocks found)
3.constructor header ( super or this – implicit or explicit )
4.instance variables initialization / instance initializer block(s) execution
5.rest of the code in the constructor
Interfaces
Clement


This order of execution is really helpful, I actually copy it down.
But I have a question related to this. Is this statement true or false: "The default constructor initializes the instance variables declared in the class. " Looks like instance variables intitialized at the time constructor is executed(between step 3 and 5), but is it OK to say constructor initializes the instance variables??
Rob, thank you for your reply.It definately take a while to read, but, yes, I agree it should be A&B.
54. which two are true?
A. An anonymous inner class can be declared inside of a method
B. An anonymous inner class constructor can take arguments in some situations
C. An anonymous inner class that is a direct subclass of Object can implements
multiple interface
D. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous inner class that is an immediate subclass of Super that implements a single interface
E. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous inner class that is an immediate subclass of Super that implements multipe interface
Answer is A.D.
I don't think D is correct. Anoymous class can either extend a class or implement one interface, can not do both. And it says here Super does not implement any interfaces, so no inheritance here. Maybe superclass of Super implements a interface?? What do u think?
Hei guys, this is not an endless loop. Byte b will overflow and become -128 ,then exit from the loop. So "Welcome to My World!" will be printed exactly once.
It will execute each time you construct by new Xxx() and execute before the constructor.
Sorry. I'm wrong. It was a local class that I declared final. Anonymous can not.Thanks guys.
which statement is true?
A. An anonymous inner class may be declared as final
B. An anonymous inner class can be declared as private
C. An anonymous inner class can implement mutiple interfaces
D. An anonymous inner class can access final variables in any enclosing scope
E. Construction of an instance of a static inner class requires an instance of
the encloing outer class
Answer is D
I think A is also correct, anonymous class are implicit final, but you can specify final as well. Compile no problem.