8.6k views
5 votes
Analyze the following code. Please select all that apply.

public class A extends B { }
class B { public B(String s) { }
a) Compilation error
b) Runtime error
c) No error
d) Code is incomplete

1 Answer

1 vote

Final answer:

The given code snippet has no error.

Step-by-step explanation:

This code snippet defines two classes: A and B. The class A extends class B, which means that A inherits all the members (methods and variables) of class B.

Class B has a constructor B(String s), which takes a string parameter. However, since class A does not have an explicit constructor, it will inherit the default constructor from class B.

Therefore, there is no compilation error, runtime error, or incomplete code in the given snippet. The correct answer is:

  1. No error

User Greg Quinn
by
8.3k points