Computer Applications

Which is a valid display() method declaration of a class Sample?

  1. Void Sample{int x}
  2. public void display()
  3. public void Show()
  4. Display{}

Objects & Classes

9 Likes

Answer

public void display()

Reason — The valid display() method declaration of a class Sample is public void display(). It includes public as the access modifier (making it accessible from anywhere), void as the return type (meaning it does not return any value) and display() as the method name with parentheses to indicate it is a function.

Answered By

6 Likes


Related Questions