Computer Applications
If the name of the class is "Yellow", what can be the possible name for its constructors?
- yellow
- YELLOW
- Yell
- Yellow
Java Constructors
ICSE 2024
6 Likes
Answer
Yellow
Reason — In Java, a constructor must have the same name as the class. It initializes an object when it is created. Since the class name is Yellow
, the constructor's name must be exactly Yellow
, matching the class name including capitalization.
Answered By
4 Likes
Related Questions
Which of the following are entry controlled loops?
(a) for
(b) while
(c) do..while
(d) switch
- only a
- a and b
- a and c
- c and d
Method which reverses a given number is:
- Impure method
- Pure method
- Constructor
- Destructor
Invoking a method by passing the objects of a class is termed as:
- Call by reference
- Call by value
- Call by method
- Call by constructor
The correct statement to create an object named mango of class fruit:
- Fruit Mango= new fruit();
- fruit mango = new fruit();
- Mango fruit=new Mango();
- fruit mango= new mango();