This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
What will be the output when you compile and execute the following program. //////////////////////////////////////////// 01: class Base 02:{ 03: static final int MAX_SIZE; 04: Base(){ 05: MAX_SIZE = 10; 06: } 07: 08: void test() { 09: MAX_SIZE++; 10: System.out.println("Base.test()"); 11: } 12: 13:} Select all valid answers. a) Compilation Error at Line 03: Blank final variable 'MAX_SIZE' may not have been initialized. It must be assigned a value in an initializer, or in every constructor. b) Compilation Error at Line 05: Can't assign a second value to a blank final variable: c) Compilation Error at Line 09: Can't assign a second value to a blank final variable: d) No errors The ans they give is A B C I wrote was C as i think when a var is final then it can be assigned a val in constructors if not given any value while declaring. ------------------ Find A Purpose In Life So Big That It Will Challenge Every Capacity To Be At Your Best.
Find A Purpose In Life So Big That It Will Challenge Every Capacity To Be At Your Best.
Nasir Khan
Ranch Hand
Joined: Nov 04, 2000
Posts: 135
posted
0
Since static members are initialized during class loading time they must be assigned a value (if they are final too) during the same period of time.. so they should be assigned either when they are declared or in static free floation blocks. [This message has been edited by Nasir Khan (edited December 15, 2000).]
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.