MCQ Single Best Answer Not Set

QYou 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?

ID: #2112 Declaration and Access Control in Java 2,059 views
Question Info
#2112Q ID
Not SetDifficulty
Declaration and Access Control in JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A It will fail to compile.
  • B Runtime error
  • C Compiles and runs with no output.
  • D Compiles and runs printing
Correct Answer: Option D

Explanation

Compiles and runs printing

Share This Question

Challenge a friend or share with your study group.