Welcome Guest | Sign in | Register
Language Fundamentals - Discussion Page For Q.3004 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Language Fundamentals > Questions and Answers

Q: You have the following code in a file called Test.java

class Base{
public static void main(String[] args){
System.out.println("Hello");
}
}

public class Test extends Base{}

What will happen if you try to compile and run this?
A. It will fail to compile. B. Runtime error
C. Compiles and runs with no output. D. Compiles and runs printing "Hello"

Answer and Explanation

Answer:Compiles and runs printing "Hello"

Explanation:
This will compile and print "Hello"
The entry point for a standalone java program is
the main method of the class that is being run.
The java runtime system will look for that method
in class Test and find that it does have such a method.
It does not matter whether it is defined in the class itself
or is inherited from a parent class.   

Comment on this Question

Name:

Loading...




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