Computer Applications
Which is a valid display() method declaration of a class Sample?
- Void Sample{int x}
- public void display()
- public void Show()
- Display{}
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.
Related Questions
A class is a template for its:
- data
- functions
- objects
- methods
An object is an instance of a:
- function
- state
- data
- class
Creating an object of a class is also referred to as:
- Initialisation
- Creation
- Formation
- Instantiation
By default, a class is declared using the access specifier …………… .
- private
- public
- protected
- secured