- It will fail to compile.
- Runtime error
- Compiles and runs with no output.
- Compiles and runs printing
Answer: Option 4
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 run-time system will look for that method in class Test and find that it should have such a method. It does not matter whether it is defined in the class itself or is inherited from a parent class.
Answer: Option 2 First execute static block, then statement block and then constructor.
1 Answers 1 viewsAnswer: Option 2 You can not override private method , private method is not availabe in subclass . In this case printName() method a class A is not overriding by...
1 Answers 87 viewsAnswer: Option 3 1. new Derived(); statement executes and invoke the non-parametrized constructor of derived class i.e. public Derived(); 2. As Derived class is a subclass of class Base so super(); executes...
1 Answers 25 viewsAnswer: Option 3 The overriding method can throw any unchecked (runtime) exception, regardless of exception thrown by overridden method. NullPointerException is RuntimeException so compiler will not complain.
1 Answers 1 viewsAnswer: Option 1 Overriding in Java simply means that the particular method would be called based on the run time type of the object and not on the compile time...
1 Answers 1 viewsAnswer: Option 2 Let'
1 Answers 4 viewsAnswer: Option 3 We cannot reduce the visibility of the inherited method from super class. If the overridden or hidden method is public, then the overriding or hiding method must...
1 Answers 6 views