Hi i am writing a mock exam, and the output they are saying is not the same when i am compiling the program.
The program is as follows:
class XTC {
static void main ( String [ ] args ) { // ---line 1
int x = true ? 10 : 20 ; // ---> line 2
System . out . println ( x ) ; // ---line 3
}
};
Here they are giving the answer that this program will compile and give an output of 10 without issuing any warnings or errors.
But when i compiled this program, the program is compiling but at run time it is giving an error that "main method not public"
Thanks in advance.
The program is as follows:
class XTC {
static void main ( String [ ] args ) { // ---line 1
int x = true ? 10 : 20 ; // ---> line 2
System . out . println ( x ) ; // ---line 3
}
};
Here they are giving the answer that this program will compile and give an output of 10 without issuing any warnings or errors.
But when i compiled this program, the program is compiling but at run time it is giving an error that "main method not public"
Thanks in advance.