Constructors in Java

A free video tutorial from Bharath Thippireddy
IT Architect and Best Selling Instructor- 700000+ students
Rating: 4.5 out of 5Instructor rating
39 courses
711,106 students

Learn more from the full course

Core Java Made Easy (Covers the latest Java 17)

Master java in quick and simple steps

27:54:21 of on-demand video • Updated November 2023

Learn the fundamentals of java and oops
Learn the building blocks of a java program
Handle Exceptions
Use flow control and looping statements
Implement encapsulation polymorphism inheritance and abstraction
Read and Write files
Write multi threaded programs
Understand and use Garbage Collection
Learn and create the different types of inner classes
Understand and master Strings
Learn collections in depth
Use functional interfaces and lambda expressions
Understand the internal of JVM
Interview Questions updated regularly
Use Concurrent Collections and Enums
Implement Internationalization and also use annotations
See how reflection API can be used to dynamically load classes ,create objects and invoke methods
Gain debugging skills
Work on various usecases and coding problems
Understand and use Wrapper Classes and Autoboxing
Use Datatypes, Literals, Variables and Typecasting
Implement Inter Thread Communication
Specify different access modifiers
Use Datatypes, Literals, Variables and Typecasting
Master Java 8 Features
Learn new features as a newer version of Java is released
Use Regular Expressions
All in quick and easy steps
What are constructors? How do they differ from other methods of the class? Can we invoke one constructor from another constructor? And can we invoke the superclass constructor from the child class constructor? Let's take a look. A constructor is a method that is used to initialize the properties of an object when it is created. It has the same name as the class name. Unlike the other methods, in this case, class Accord, the constructor is also Accord. But the other methods start and stop have different names of their own. But the constructor name is the same name as the class name. The constructor is only invoked when the instance or the object of that class is created. Whereas the other methods can be invoked as many number of times as we want. To invoke other constructors in the same class, we use the this method. And we can pass in the parameters just like any other method. And if the class Accord extends class Honda, to invoke the superclass' constructor, the Honda's constructor from within the child class constructor, we use the super method and pass in any parameters.