Constructors in Java

Bharath Thippireddy
A free video tutorial from Bharath Thippireddy
IT Architect and Best Selling Instructor- 400000+ students
4.5 instructor rating • 31 courses • 414,423 students

Learn more from the full course

Core Java Made Easy (Covers the latest Java 15)

Master java in quick and simple steps

22:48:05 of on-demand video • Updated April 2021

  • Learn the fundamentals of java and oops
  • Learn the building blocks of a java program
  • Handle Exceptions
  • Read and Write files
  • Use flow control and looping statements
  • Implement encapsulation polymorphism inheritance and abstraction
  • 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 Question updated regularly
  • All in quick and easy steps
English 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.