#4.2 Constructor in Java Theory
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.
Java and Spring Framework For beginners with Spring Boot : - http://bit.ly/3LDMj8D
Java Tutorial for Beginners (2023) :- http://bit.ly/3yARVbN
Github :- https://github.com/navinreddy20/Java-Tutorial-for-Beginners-Crash-Course
Instagram : https://www.instagram.com/navinreddyofficial/
Linkedin : https://in.linkedin.com/in/navinreddy20
Discord : https://discord.gg/aXPF5hV7
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
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «#4.2 Constructor in Java Theory», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.