This is question no 11 in chapter 2 in K S book for
SCJP 1.5
Given:
class Uber {
static int y = 2;
Uber(int x){this(); y= y* 2;}
Uber(){y++;}
}
class Minor extends Uber{
Minor (){ super(y); y = y+3;}
public static void main(
String[] args) {
new Minor();
System.out.println(y);
}
}
What is the result?
a. 6
b. 7
c. 8
d. 9
e. Compilation fails.
f. An exception is thrown
Answer Given is "d"
But According to me it should be " e "
Reason:
1. Main method should be in a Public class but class Minor is not declared as public .
Please clarify