hello,
i came across the fallowing questions in a mock exam....
question 1)
class XTC {
static void main ( String [ ] args ) { // ---> line 1
int x = true ? 10 : 20 ; // ---> line 2
System . out . println ( x ) ; // ---> line 3
}
}
here i have mark....that it will rise an Exception at runtime saying that there is no main method..
but the Answere is : compiles and prints 10 in the console.
question 02)
class ZZY {
protected static void main ( String [ ] ka ) {
Test t = new Test ( ) ;
t . getInner ( ) . doSomething ( ) ;
}
}
Options :
a . Compiler error - class Test . Inner not accessible from ZZY
b . Compiler error - doSomething is declared abstract in Greater
c . Compiler error - doSomething in Inner can't override doSomething of Greater - the access modifier is not present in Greater
d . Compiles & prints " I'm in inner " to the console on execution
how came the Ans is 'd'? here the main methos is protected....won't it give runti,e exception??
plz give me reply....
thanks in advance
krishna.