- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Does constructor return any value in Java?
No, constructor does not return any value.
- While declaring a constructor you will not have anything like return type.
- In general, Constructor is implicitly called at the time of instantiation.
- And it is not a method, its sole purpose is to initialize the instance variables.
Example
public class Sample{ public Sample(){ System.out.println("This is a constructor"); } public static void main(String args[]){ Sample obj = new Sample(); } }
Output
This is a constructor
- Related Articles
- Java constructor return a value but, what?
- Does a constructor have a return type in Java?
- Is there any alternative solution for static constructor in java?
- What is the return type of a Constructor in Java?
- What value does read() method return when it reaches the end of a file in java?
- What happens if we call "super()" in a constructor without extending any class, in java?
- Enum constructor in Java
- Constructor overloading in Java
- Default constructor in Java
- Java default constructor
- Java parameterized constructor
- Java copy constructor
- How does constructor method __init__ work in Python?
- Constructor Chaining In Java programming
- Constructor Overloading In Java programming

Advertisements