English

What is a method with a class name known as?

Advertisements

Question

What is a method with a class name known as?

Short Answer
Advertisements

Solution

A method having the same name as its class is known as a Constructor in Java. A constructor is a special member of a class that is automatically called when an object is created. It is used to initialize the data members of an object and does not have a return type.

shaalaa.com
  Is there an error in this question or solution?
Chapter 4: Objects - EXERCISE [Page 107]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 4 Objects
EXERCISE | Q 10. (i) | Page 107
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×