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 ***.



Leave a Reply 7

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


dwin

dwin

answer is: A C
A: class Writer already signature “abstract”, it can’t do the implementation of abstract method.
B: void write (String s); –> abstract void write (String s);
C: overloading is ok.
D: void write (string s) { } –> public void write (string s) { }
E: write () {} –> void write () {} or add return type that could be overloading.

duff

duff

In C overloading will be successful if
abstract void write ();

Sanjukta

Sanjukta

None of the options are correct. The method modifier needs to be public.
@Override
public void write(String s) {

}

leo yu

leo yu

A, D is correct, tested
A) inherit the abstract method of interface
B) should implement abstract method or override abstract method: abstract void write(String s), or void write(String s){..}
C) should be abstract void write();
D) implementation of abstract method
E) should be abstract void write();

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 () {}
}