Which three are true?

Given these facts about Java types in an application:

– Type x is a template for other types in the application.

– Type x implements dostuff ().

– Type x declares, but does NOT implement doit().

– Type y declares doOther() .

Which three are true?

Given these facts about Java types in an application:

– Type x is a template for other types in the application.

– Type x implements dostuff ().

– Type x declares, but does NOT implement doit().

– Type y declares doOther() .

Which three are true?

A.
Type y must be an interface.

B.
Type x must be an abstract class.

C.
Type y must be an abstract class.

D.
Type x could implement or extend from Type y.

E.
Type x could be an abstract class or an interface.

F.
Type y could be an abstract class or an interface.

Explanation:
Unlike interfaces, abstract classes can contain fields that are not static and final, and they can contain implemented methods. Such abstract classes are similar to interfaces, except that they provide a partial implementation, leaving it to subclasses to complete the implementation. If an abstract class contains only abstract method declarations, it should be declared as an interface instead.

Note:
An interface in the Java programming language is an abstract type that is used to specify an interface (in the generic sense of the term) that classes must implement. Interfaces are declared using the interface keyword, and may only contain method signature and constant declarations (variable declarations that are declared to be both static and final). An interface may never contain method definitions.

Note 2: an abstract class is a class that is declared abstract–it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon)



Leave a Reply 3

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


Tim

Tim

Type x implements dostuff ().

Shamitha Silva

Shamitha Silva

Here Y could be an interface or an Abstract Class. Because it says “y declares doOther()”. It means that it simply declares it without a method body. So A and C are wrong.

E is wrong because statements say “x implements dostuff ()”