Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
Can a constructor have different name than a Class name in Java?
Home
JAVA
Can a constructor have different name than a Class name in Java?
+2
votes
asked
May 31, 2020
in
JAVA
by
SakshiSharma
Can a constructor have different name than a Class name in Java?
#java-main-class
#main-class-java
#java-constructors
#constructors-java
Java-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
May 31, 2020
by
Robindeniel
Constructor in Java must have same name as the class name and if the name is different, it doesn’t act as a constructor and compiler thinks of it as a normal method.
Related questions
+2
votes
Q: Can we have any other return type than void for main method in Java?
asked
May 31, 2020
in
JAVA
by
SakshiSharma
#java-void-main
#java-method-main
#java-void-method
Java-questions-answers
0
votes
Q: Can you make a constructor final in Java?
asked
Feb 9, 2021
in
JAVA
by
SakshiSharma
#constructor-final
final-java
java-final
Java-questions-answers
0
votes
Q: What should be the execution order, if a class has a method, static block, instance block, and constructor, as shown below?
asked
Apr 8, 2021
in
JAVA
by
SakshiSharma
java
java-questions-and-answers
java-mcq
core-java-mcq
java-multiple-choice-questions
java-questions-2021
java-interview-questions
java-advanced-questions
Java-questions-answers
0
votes
Q: If a child class inherits base class then are the constructor of the base class also inherited by the child class?
asked
Oct 27, 2020
in
JAVA
by
sharadyadav1986
#child-class-inherit
Java-questions-answers
0
votes
Q: What is a constructor in java?
asked
Oct 27, 2020
in
JAVA
by
sharadyadav1986
#constructor-java
#java-constructor
Java-questions-answers
0
votes
Q: A java constructor returns a value, but what?
asked
Oct 22, 2020
in
JAVA
by
sharadyadav1986
#java-constructor
#constructor-returns
Java-questions-answers
0
votes
Q: What is a constructor in java?
asked
Oct 19, 2020
in
JAVA
by
rahuljain1
#consructor-in-javam
#java-constructor
Java-questions-answers
+1
vote
Q: What is the difference between a constructor and a method in Java?
asked
May 30, 2020
in
JAVA
by
Robindeniel
#java-constructor
#java-methods
#methods-java
#constructor-vs-method
#java-constructor-vs-method
Java-questions-answers
0
votes
Q: What are the ways to achieve Constructor chaining in Java?
asked
Feb 8, 2021
in
JAVA
by
SakshiSharma
#constructor-overloading
constructor-change
java-constructor
Java-questions-answers
0
votes
Q: How to achieve Constructor Overloading in Java with examples
asked
Oct 27, 2020
in
JAVA
by
sharadyadav1986
#constructor-overloading
Java-questions-answers
...