Single Choice
Not Set
QWhat is the prototype of the default constructor? public class Test { }
ID: #2184
Java Constructor and Methods
13,164 views
Question Info
#2184Q ID
Not SetDifficulty
Java Constructor and MethodsTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
public Test( )
A constructor in Java is similar to a method that is invoked when an object of the class is created.
Unlike Java methods, a constructor has the same name as that of the class and does not have any return type. For example,
class Test {
public Test() {
// constructor body
}
}
Here, Test() is a constructor. It has the same name as that of the class and doesn't have a return type.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic