Forums Register Login

voodoo exam_1 question

+Pie Number of slices to send: Send
By changing which line in the following code can you make the class compile with no errors?
class Xtc {
protected static void main(String args[]) {//line 1
byte b = 10, //line2
c = 10 , //line 3
x= (byte) (b + c) ; //line 4
System.out.println(" x is " + x); //line5
}
}
Options
a) line 1
b) line 2
c) line 3
d) line 4
e) line 5
f) None , the class compiles with no error and prints 20
He says the ans is (f) None
I marked it as (a) since main must to public as the class will compile only if line1 is changed to public static void main ( String args[])
can anyone tell me why the an is none, i tried compiling the program but compiler says main must be public and static.
thanks in advance.
bani
+Pie Number of slices to send: Send
The "blatant advertising" forum is really for product announcements. This post seems much more appropriate to one of the study forums,so I've moved it to "Programmer Certification Study" for you.
+Pie Number of slices to send: Send
Please don't post identical threads in multiple forums. Please continue the discussion in the original thread.
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


Reply locked
This thread has been viewed 636 times.
Similar Threads
why does it do not show an compile time erroe at line 3?
JQplus
A SCJP exam question (about array variable assign)
Final Variables are Very PowerFull (Check inside))
interface to class assignment
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:32:56.