Welcome Guest | Sign in | Register
Flow Control - Discussion Page For Q.2774 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Flow Control > Questions and Answers

Q: which has public static void main(), so it will throw runtime error. what will be the out put of following code ?

G.java

class F{
static void main(String args[]){
System.out.println(ā€œGā€);
}
}

class G{
static void main(String args[]){
System.out.println(ā€œFā€);
}
}
A. compile time error B. run time error

C. F D. G

Answer and Explanation

Answer:F

Explanation:
here, in a single file we have declared two class which has main method. The name using which you will save that class will execute and display the output.you can write multiple main methods in java only in different class ,not in a single class.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.