MCQ Single Best Answer Not Set

QGiven the following piece of code:
public interface Guard{
        void doYourJob();
}
abstract public class Dog implements Guard{ }
which of the following statements is correct?

ID: #2278 Java Interfaces And Abstract Classes MCQ 2,044 views
Question Info
#2278Q ID
Not SetDifficulty
Java Interfaces And Abstract Classes MCQTopic

Choose the Best Option

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

  • A This code will not compile, because method doYourJob() in interface Guard must be defined abstract.
  • B This code will not compile, because class Dog must implement method doYourJob() from interface Guard.
  • C This code will not compile, because in the declaration of class Dog we must use the keyword extends instead of implements.
  • D This code will compile without any errors.
Correct Answer: Option D

Explanation

This code will compile without any errors.

Share This Question

Challenge a friend or share with your study group.