Following code will result in: class A { public static void main(String [] args) {A a = new B(); }} class B extends A {}

  1. Compiler error

  2. Runtime Exception

  3. No errors


Correct Option: C

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Compiler error - This option is incorrect because there are no syntax or compilation errors in the given code. The code compiles successfully.

Option B) Runtime Exception - This option is incorrect because there are no runtime exceptions thrown in the given code. The code executes without any errors.

Option C) No errors - This option is correct because there are no syntax errors or runtime exceptions in the given code. The code compiles successfully and executes without any issues.

The correct answer is C) No errors. This option is correct because the code is syntactically correct and executes without any errors.

Therefore, the code will result in no errors.

Find more quizzes: