Question
interface Worm
{
int teeth=2;
}
class BookWorm implements Worm
{
int teeth=4;
void show()
{
teeth= 5;
System.out.println("Teeth: " + teeth);
}
}
public class InterfaceTest4
{
public static void main(String[] args)
{
new BookWorm().show();
}
}
a.
Teeth: 4
b.
Teeth: 5
c.
Compiler error as teeth is a constant in Worm interface.
d.
None of the above
Posted under Java Programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of the below Java program with an Interface?
Similar Questions
Discover Related MCQs
Q. A Java Interface can not declare constructors. State TRUE or FALSE.
View solution
Q. Java 8 (Java 1.8) introduced the ___ feature.
View solution
Q. Java Interface static methods have ___ compatibility with the existing project code.
View solution
Q. Java Interface DEFAULT methods have ___ compatibility with the existing project code.
View solution
Q. The DEFAULT methods of an Interface are suitable mostly for ___ type of projects.
View solution
Q. Is it possible to remove the keyword DEFAULT and make the method abstract again in an Interface, if the Interfacebelongs to a Closed-Source project?
View solution
Q. The annotation used in Java to override the method of a super-class or interface by the subclass or implementing class is ___.
View solution
Q. It is ___ to override the static method of an Interface in Java.
View solution
Q. A Java static method can not be ___.
View solution
Q. A Superinterface is comparable to a Superclass. State TRUE or FALSE.
View solution
Q. A Static method of an Interface should be accessed with _____ and a DOT operator.
View solution
Q. What is a package in Java?
View solution
Q. Choose the correct syntax of a Java Package below.
View solution
Q. The keyword used to declare a Java package is ____.
View solution
Q. What is the maximum number of Java Class files that can be kept inside a single Java Package?
View solution
Q. The name of a package is the name of the ___ in Java.
View solution
Q. It is possible to declare a package and import another package within the same Java class file. State TRUE or FALSE.
View solution
Q. The keyword used to import a package into Java class or Interface is ___.
View solution
Q. Which is the correct syntax to import a Java package below?
View solution
Q. Choose correct declaration and importing of packages in Java.
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!