42 Constructor in Java Theory











>> YOUR LINK HERE: ___ http://youtube.com/watch?v=YqBVgUh64Ks

In this lecture we are discussing: • 1)Know some terminology and term uses in java • 2)What we need to call any method in java ? • 3)What is Constructor ? • 4)Use of constructor? • 5)Type of constructor and glance of constructor overloading? • #1 • key terminology : • i) return type int, float, void • ii) access specifiers public, private, default, protected--- we will talk this on special lecture • iii) Constructor --- particularly this topic discuss in lecture. • iv) static and main • #2 • What we need to call any method in java? • :-- We need a object to call any method • :-- then question arise how we call main method without object, from main our program not started • for starting program we need object and for creating object we need some space to create object. If this happen we cannot run our program. • :--To solve this we make main method as static .It means for static method we do not require object to call. • :--JVM call main method without creating object. • #3 • What is Constructor? • It is special member method of object. We can say it is special type of setter (to set the value of instance variable) used to set • value of instance variable. It is called when we create our object and it has no any return type. • e.g • class A{ • int a; • A(){ //non parametrized constructor • //if you don’t declare constructor by default constructor available for every class • a=5; //initialize 5 as default value of i • } • public void wish(){ • System.out.println( wish ); • } • } • public class Main{ • public static void main(String []args){ • A obj=new A(); // obj is reference variable • // new A() is used to create object • //with creation of object automatically call constructor of A class • obj.wish(); //call method • } • } • #4 • Use of Constructor • -- constructor is used to create object • -- Constructor is used to allocate memory in heap memory. • -- Work as seater (to seat value of instance variable) • -- constructor overloading (we shall talk in other lecture) • -- constructor chaining (After learning this() and super() we can discuss) • #5 • Type of Constructor • i) default constructor (this is also not parametrized constructor but when we not write constructor then by default jvm create) • ii) parametrized constructor • iii) non parametrized constructor • e.g • class A{ • int a; • A(){ • //non parametrized constructor • } • A(int i){ • a=i; //parametrized constructor • } • } • class B{ • //in this case jvm provide by default non parametrized constructor • } • Note: • i)When we use multiple constructor in same class then it is known as constructor overloading. • we are done this in class A. Right now we are not study polymorphism that’s why we are not talk more about constructor overloading. • ii) When we will study polymorphism we can talk about method overloading. Which will be same as a constructor overloading. • This video shows what is constructor. How to use constructor? • What are different types of constructor. • Check out our courses: • Java Full Stack and Spring AI - https://go.telusko.com/JavaSpringAI • Coupon: TELUSKO10 (10% Discount) • DevOps with AWS: From Basics to Mastery : https://go.telusko.com/DevOpsAWS • Coupon: TELUSKO10 (10% Discount) • Master Java Spring Development : https://go.telusko.com/masterjava • Coupon: TELUSKO20 (20% Discount) • Udemy Courses: • Spring: https://go.telusko.com/udemyteluskosp... • Java:- https://go.telusko.com/udemyteluskojava • Java Spring:- https://go.telusko.com/Udemyjavaspring • Java For Programmers:- https://go.telusko.com/javaProgrammers • Python : https://go.telusko.com/udemyteluskopy... • Git : https://go.telusko.com/udemyteluskogit • Docker : https://go.telusko.com/udemyteluskodo... • For More Queries WhatsApp or Call on : +919008963671 • website : https://courses.telusko.com/ • Github :- https://github.com/navinreddy20/Java-... • • Instagram :   / navinreddyofficial   • Linkedin :   / navinreddy20   • Discord :   / discord   • More Learning : • Java - https://bit.ly/3xleOA2 • Python :- https://bit.ly/3H0DYHx • Django :- https://bit.ly/3awMaD8 • Spring Boot :- https://bit.ly/3aucCgB • Spring Framework :- https://bit.ly/3GRfxwe • Servlet JSP :- https://bit.ly/3mh5CGz • Hibernate Tutorial :- https://bit.ly/3NWAKah • Rest API | Web Service Tutorial :- https://bit.ly/38RJCiy • Git :- https://bit.ly/3NUHB3V • JavaScript :- https://bit.ly/3mkcFys • Kotlin :- https://bit.ly/3GR2DOG

#############################









Content Report
Youtor.org / YTube video Downloader © 2025

created by www.youtor.org