What code should be inserted?

Given:

public class Bark {
// Insert code here – Line 5
public abstract void bark(); // Line 6
} // Line 7
// Line 8
// Insert code here – Line 9
public void bark() {
System.out.println(“woof”);
}
}
}

What code should be inserted?

Given:

public class Bark {
// Insert code here – Line 5
public abstract void bark(); // Line 6
} // Line 7
// Line 8
// Insert code here – Line 9
public void bark() {
System.out.println(“woof”);
}
}
}

What code should be inserted?

A.
5.class Dog {
9. public class Poodle extends Dog {

B.
5. abstract Dog {
9. public class poodle extends Dog {

C.
5. abstract class Dog {
9. public class Poodle extends Dog {

D.
5. abstract Dog {
9. public class Poodle implements Dog {

E.
5. abstract Dog {
9. public class Poodle implements Dog {

F.
5. abstract class Dog {
9. public class Poodle implements Dog {

Explanation:
Dog should be an abstract class. The correct syntax for this is: abstract class Dog { Poodle should extend Dog (not implement).



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Jazz

Jazz

“C”

Explanation:
Dog must be a abstract Class & Poodle must Extends(not Implement) Dog.

James

James

The Answer is C.

If a class specifies abstract methods, it must be abstract itself. However, an abstract class can contain both abstract and non-abstract methods. Abstract methods must not have any defined body, not even an empty one (i.e., {}).

A class extends (inherits from) another base class. A class implements an interface. Also an interface extends (inherit from) another base interface. A class extends zero or one base class and implements zero, one, or more interface(s).