Answer to Question #348994 in Java | JSP | JSF for stephanie

Question #348994

Create an interface called StudentInterface. This interface has the following abstract method:

public void study(String subject);

The Student class implements this interface, and provides an implementation for study() which displays that the student is studying a certain subject.

(Note what happens if you don’t  implement study().)




1
Expert's answer
2022-06-07T17:44:31-0400
interface StudentInterface {
    void study(String subject);
}

class Student implements StudentInterface {
    // If `study` method is not implemented, then a compilation error happens
    public void study(String subject) {
        System.out.println("The student is studying " + subject);
    }
}

class Test {
    public static void main(String[] args) {
        Student student = new Student();
        student.study("Math");
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS