Which two statements are true about the writer class?

Given:

Which two statements are true about the writer class?

Given:

Which two statements are true about the writer class?

A.
It compiles without any changes.

B.
It compiles if the code void write (String s); is added at line***.

C.
It compiles if the code void write (); is added at line ***.

D.
It compiles if the code void write (string s) { } is added at line ***.

E.
It compiles if the code write () {}is added at line ***.

Explanation:

An abstract class does not need to implement the interface methods.



Leave a Reply 12

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


Tim

Tim

The question is wrong – only A is the answer, but asked for “two” correct statements.

liar

liar

c is correct also. notice it overloads

Xx

Xx

overloads =>void write() {}
c no “{}”

Freek

Freek

Only A is correct.

B and D must be public at least to be an override or implementation

C might be an overload, but should either be abstract or have an implementation.

E is missing the returntype.

César Martín

César Martín

B and C, tested.
B overwrites interface method,
C only adds a new abstract method to the abstract class.

zdeDu

zdeDu

AE are correct.

Xx

Xx

E no Return type

mknet

mknet

A,E >> for C compilation fails.

gelete

gelete

A

interface Writable {
void write (String s);
}

abstract class Writer implements Writable {
// Line ***

// A True

// B False
// Cannot reduce the visibility of the inherited method from Writable
// This method requires a body instead of a semicolon
// void write (String s);

// C False
// This method requires a body instead of a semicolon
// void write ();

// D False
// Cannot reduce the visibility of the inherited method from Writable
// void write (String s) { }

// E False
// Return type for the method is missing
// write () {}
}