- 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
Default constructor in Java
Java compiler automatically creates a default constructor (Constructor with no arguments) in case no constructor is present in the java class. Following are the motive behind a default constructor.
Create the Object
Call the super class constructor()
Initialize all the instance variables of the class object.
Example
public class Tester { int a; String b; public static void main(String[] args) { //Default constructor //is called to create a new object Tester t = new Tester(); //print the default values System.out.println(t.a); System.out.println(t.b); } }
Output
0 null
- Related Articles
- Java default constructor
- How to create a default constructor in Java?
- What are the differences between default constructor and parameterized constructor in Java?
- Default constructor in C#
- What do you mean by default constructor in Java?
- C++ default constructor
- What is the purpose of a default constructor in Java?
- Can we initialize static variables in a default constructor in Java?
- Do static variables get initialized in a default constructor in java?
- What is the default constructor in C#?
- What is default constructor in C# programs?
- What is a default constructor in JavaScript?
- Constructor overloading in Java
- Enum constructor in Java
- Java parameterized constructor

Advertisements