8.6 Object Creation in Inheritance | Constructor | Super

  Рет қаралды 97,498

Telusko

Telusko

9 жыл бұрын

In Java, base class constructor with no argument gets automatically called in derived class constructor.
if you want to call parameterized contructor of base class, then use super().
Check out our website: www.telusko.com
Follow Telusko on Twitter: / navinreddy20
Follow on Facebook:
Telusko : / teluskolearnings
Navin Reddy : / navintelusko
Follow Navin Reddy on Instagram: / navinreddy20
Subscribe to our other channel:
Navin Reddy : / @navinreddy
Telusko Hindi :
/ @teluskohindi

Пікірлер: 29
@veerapanenichenna8756
@veerapanenichenna8756 9 жыл бұрын
Nice information.. Thank you Navin
@naveena9808
@naveena9808 8 жыл бұрын
excellent teaching sir. Can you plz add access specifier topic with hands on coding, to show how private, protected and public members are accessed from derived class/outside world. this would cover more core concept of inheritance.
@vladanulardzic5859
@vladanulardzic5859 5 жыл бұрын
Well done ! Keep on ...
@mohammedviso2269
@mohammedviso2269 7 жыл бұрын
Great tutorial
@taylorstarcevic1015
@taylorstarcevic1015 5 жыл бұрын
I think it would help people follow a little better if the constructor with the int parameter also printed out the int in the text line as well.
@LukaszSkyWalker
@LukaszSkyWalker 6 жыл бұрын
Thx!!
@MayankKaushal1994
@MayankKaushal1994 7 жыл бұрын
Sir I have an doubt regarding object creation in inheritance. Is it true that When a object of sub class created object of super class is not created. ?? I find some answers on stackoverflow that parent class uses the memory of child class object to instantiate its constructor. Hence only one object is created.
@instaminox
@instaminox 6 жыл бұрын
You are right! I agree!
@shuvshaw9594
@shuvshaw9594 4 жыл бұрын
very helpful
@bhaveshsonar6716
@bhaveshsonar6716 9 жыл бұрын
super!!
@i_karank
@i_karank 7 жыл бұрын
does java support heirarchical inherit?
@projectt4359
@projectt4359 7 жыл бұрын
sir, can you explain how reference of (super class) can hold the object of (sub class) and the memory allocation while instantiation of sub class.
@vivekvikram4866
@vivekvikram4866 4 жыл бұрын
It's typecasting
@Thegamer-yp7qq
@Thegamer-yp7qq 8 жыл бұрын
is any thing in subclass . we can find it in superclass. . ??
@elanza48
@elanza48 6 жыл бұрын
How can we call a subclass method without calling the default method of the superclass ?
@khandarerahul7805
@khandarerahul7805 8 жыл бұрын
expalin it if i am using it with multiple inheritance.... java dsnt support multi inheritance but if the mult inheritence wld be ther in java hw the object creation takes place...???
@ayechanaungthwin3919
@ayechanaungthwin3919 5 жыл бұрын
Java doesn't support Multiple Inheritance like C++. If a class can be inherited many classes, it will become a GOD class. And if we use it, there will be many dependencies. That's why it only support multi-level inheritance. (E.g., If a person knows everything in every situations, he's a big shit, useless!)
@vaishnavibhagwat8220
@vaishnavibhagwat8220 3 жыл бұрын
Sir How to differentiate between method and constructor means how we will know which is method n which is constructor. And when how we will know when we have to use constructor or method?
@omkarjoshi2095
@omkarjoshi2095 4 жыл бұрын
why do I get an error when I don't have a default constructor in parent class but a parameterised constructor and have child class that extends parent class
@souidmehdi7881
@souidmehdi7881 6 жыл бұрын
can you enable subtitled mode please sir ?
@bgpattar
@bgpattar 7 жыл бұрын
Naveen, i could not create "object of super class with memory allocation of subclass"
@gomes8335
@gomes8335 5 жыл бұрын
same
@Sacch_u
@Sacch_u 8 жыл бұрын
Sir can an object of sub class and and referance of super class can be created?
@dpavith111
@dpavith111 7 жыл бұрын
Kunal Suchde
@projectt4359
@projectt4359 7 жыл бұрын
sir, can you explain it how??
@ashishshah3899
@ashishshah3899 5 жыл бұрын
Why we cannot inherit a class with the private constructor?
@harshsharma57
@harshsharma57 3 жыл бұрын
because a subclass always extends all the non private features of its super class
@sampathrajaraghupathikagup8723
@sampathrajaraghupathikagup8723 4 жыл бұрын
how to stop calling the super();
@shuvshaw9594
@shuvshaw9594 4 жыл бұрын
package javaapplication132; public class JavaApplication132 { public static void main(String[] args) { System.out.println("output 1"); parent var1=new parent(); // executes only constructor of parent class *(i wil create multiple object of same class thats why variable name is var1) System.out.println("output 2"); parent var2=new parent(1); // executes only parametarised constructor of parent class *(i wil create multiple object of same class thats why variable name is var2) System.out.println("output 3"); child var3=new child(); // executes only constructor of child class and also constructor of parent class(which is called super class) because child class is extend of parent class *(i wil create multiple object of same class thats why variable name is var1) System.out.println("output 4"); child var4=new child("pass string value"); // executes only parametarised constructor of child class and also the constructor of parent class(which is called super class) *(i wil create multiple object of same class thats why variable name is var2) } } class parent { public parent() //create constructor of class parent, because constructor name is same as class name { System.out.println("constructor in class parent"); } public parent(int i) //create parametarised constructor of class parent, because constructor name is same as class name { System.out.println("parametarised constructor in class parent"); } } class child extends parent { public child() //create constructor of class parent, because constructor name is same as class name { System.out.println("constructor in class child"); } public child(String i) //create parametarised constructor of class parent, because constructor name is same as class name { System.out.println("parametarised constructor in class child"); } }
8.7 Polymorphism in Java
9:10
Telusko
Рет қаралды 276 М.
#51 This and Super Method in Java
12:11
Telusko
Рет қаралды 91 М.
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 58 МЛН
Constructor Concept and This Keyword in Java
45:04
Naveen AutomationLabs
Рет қаралды 60 М.
8.4 Inheritance Example in Java Single Level
6:45
Telusko
Рет қаралды 119 М.
Super Keyword in Java Full Tutorial - How to Use "super"
11:33
Coding with John
Рет қаралды 197 М.
this keyword in Java Hindi
12:36
Smart Programming
Рет қаралды 323 М.
Java Inheritance and Constructors
12:57
Brian Fleischman
Рет қаралды 19 М.
Java super keyword 🦸‍♂️
8:09
Bro Code
Рет қаралды 91 М.
8.18 Abstract Class in Java Example
15:27
Telusko
Рет қаралды 382 М.
Java Polymorphism Fully Explained In 7 Minutes
7:16
Coding with John
Рет қаралды 299 М.