Java Tutorial For Beginners 25 – Inheritance in Java

///Java Tutorial For Beginners 25 – Inheritance in Java

Java Tutorial For Beginners 25 – Inheritance in Java

FavoriteLoadingAdd to favorites

java inheritance constructor
java inheritance vs interface
java inheritance static variables
java inheritance static methods
java vererbung
java subclass
java extend class
java class declarationjava inheritance example
java inheritance example program
java polymorphism
java inheritance constructor
java multiple inheritance
java inheritance interview questions
java inheritance pdf
java inheritance definition

source

Java468x60
By |2019-09-05T22:19:32+00:00September 5th, 2019|Java Video Tutorials|43 Comments

43 Comments

  1. Autif Kamal September 5, 2019 at 10:19 pm - Reply

    The quality of the audio does affect the quality of the video. You should've addressed that. You seemed to entirely neglect them.

  2. aditya parashar September 5, 2019 at 10:19 pm - Reply

    which software you are using??

  3. Miguel Anaya Bahena September 5, 2019 at 10:19 pm - Reply

    De todas formas solo me funciona un audifono

  4. saniya .s September 5, 2019 at 10:19 pm - Reply

    Audible only in right ear👌

  5. salman mohammad September 5, 2019 at 10:19 pm - Reply

    Can we use perform as method

  6. Umid Kurbanov September 5, 2019 at 10:19 pm - Reply

    Java is very smiliar with C#

  7. LYJManchesterUnited September 5, 2019 at 10:19 pm - Reply

    My right speaker is spoilt need to buy a new one

  8. Parijat Dhar September 5, 2019 at 10:19 pm - Reply

    Actually, this is an example of hierarchical inheritance as the super-class is inherited by both sub-classes.

  9. Japhet Anciado September 5, 2019 at 10:19 pm - Reply

    My left ear seem to enjoy the vid

  10. Sophia Man September 5, 2019 at 10:19 pm - Reply

    I am not the only one who looked for another pair of earphones. LOL.

  11. 安妮 September 5, 2019 at 10:19 pm - Reply

    Excellent example and very well explained! 👍

  12. Patrick Lee September 5, 2019 at 10:19 pm - Reply

    fix your audio pls

  13. Ankur Gupta September 5, 2019 at 10:19 pm - Reply

    sound is not clear

  14. Latoya Clarke September 5, 2019 at 10:19 pm - Reply

    very good tutorial

  15. Immortal Legends September 5, 2019 at 10:19 pm - Reply

    User interface program in same method

    public class MyProgram{
    public static void main(String[] args) {
    rectangle rect =new rectangle();
    triangle triag=new triangle();
    rect.valset();
    triag.valset();
    System.out.println("The Area of Rectangle is: " + rect.Area());
    System.out.println("The area of triangle is: " + triag.Area());
    }
    }

    import java.util.Scanner;
    public class polygon {
    protected int length;
    protected int breadth;
    public void valset() {
    int l;
    int h;
    System.out.println("Please enter Length: ");
    Scanner a=new Scanner(System.in);
    l = a.nextInt();
    System.out.println("Please enter breadth or height: ");
    Scanner b =new Scanner(System.in);
    h =b.nextInt();
    length = l;
    breadth = h;
    }
    }

    public class rectangle extends polygon {
    public double Area() {
    return(length*breadth);
    }
    }

    public class triangle extends polygon {
    public double Area() {
    return(length*breadth)/2;
    }
    }

  16. Patryk Rasiak September 5, 2019 at 10:19 pm - Reply

    Is someone watching it in 2018? 😀

  17. Smart Programming September 5, 2019 at 10:19 pm - Reply

    nice tutorial, keep it up 👍🙂

  18. Maknah September 5, 2019 at 10:19 pm - Reply

    Is MyClass the Runner?

  19. Joshua Bramble September 5, 2019 at 10:19 pm - Reply

    Awesome Video man!! thanks a bunch, got me out of a pinch

  20. anudip dey September 5, 2019 at 10:19 pm - Reply

    Can I set the values of height and width in Polygon class and the sub classes can access it?

  21. Lisa Mango September 5, 2019 at 10:19 pm - Reply

    I thought my headphones were broken, so then I went on a 10-minute search to find other headphones, then realized they were broken too. Then I read the comments. Lesson: read the comments first.

  22. Kyle Fitz September 5, 2019 at 10:19 pm - Reply

    This dude swallows too often..

  23. Patrick Nuqui September 5, 2019 at 10:19 pm - Reply

    Please watch my "How to replace the battery in your smoke detector FOR ABSOLUTE BEGINNERS."

  24. SUNGHYUN LEE September 5, 2019 at 10:19 pm - Reply

    Hi Guys.
    Does anyone know how to use a value from other Method (e.g public class int calculate() {})?
    How should i use the variable that was set in another method or class?
    Thanks all!

  25. navaneetha krishnan September 5, 2019 at 10:19 pm - Reply

    you did not explain types of inheritance,
    why multiple inheritance is not possible..??

  26. Java September 5, 2019 at 10:19 pm - Reply

    In inheritance you can take the variable and method for other class and difference between interface is necessary use abstract you can only take the method, I´m right?

  27. Likhit Reddy September 5, 2019 at 10:19 pm - Reply

    please fix the audio, it is irritating while on the headphones.

  28. Rishabh Srivastava September 5, 2019 at 10:19 pm - Reply

    Hi ProgrammingKnowledge,

    While writing the code of inheritance I declared the method to set values in polygon as static and now I am getting warning at the variables being set as "can not make static reference to non static field height"

    Please see the code written by me for Polygon class:

    public class Polygon {

    protected int height;
    protected int width;

    public static void setValues(int l,int w)
    {
    height= l; // warning "can not make static reference to non static field height"
    width= w; // warning "can not make static reference to non static field width"

    }

    Once I remove the "static" keyword from setValues method the error is gone.

  29. Umut Özdemir September 5, 2019 at 10:19 pm - Reply

    dat nois makes me sleepy m8

  30. GoodGameYourDead - Minecraft And More September 5, 2019 at 10:19 pm - Reply

    FIX YOUR FREAKING SMOKE DETECTOR

  31. House of Doom September 5, 2019 at 10:19 pm - Reply

    Why PUBLIC is not used in place of PROTECTED? And is there any difference in :- (a) public int height;(b) int height; is there any difference between (a) & (b)?

  32. Aquieb Shaikh September 5, 2019 at 10:19 pm - Reply

    volume quality is low it sucksss..

  33. Nadim Baraky September 5, 2019 at 10:19 pm - Reply

    There's a small issue in the area() in Rectangle class. You must cast the height*width to (double) before dividing by 2.
    Here by chance the result was true. If it were say 50.xx it'll be also 50. Since it's applying "Integer division" & then, returning it as a double.

  34. Oliver Waller September 5, 2019 at 10:19 pm - Reply

    Get creative with it. Only a few hours in and I feel like I am learning quite a bit. Try getting user input for height and width like this one:

    public static void main(String[] args) {

    Rectangle rec = new Rectangle();

    System.out.println("Area of a Rectangle");
    System.out.println(" —————–");
    System.out.println("| |");
    System.out.println("| |");
    System.out.println("| |");
    System.out.println(" —————–");
    System.out.println("Enter height of Rectangle");
    Scanner scan = new Scanner(System.in);
    double user_input_rec_height = scan.nextDouble();

    System.out.println("Enter width of Rectangle");
    Scanner scan1 = new Scanner(System.in);
    double user_input_rec_width = scan.nextDouble();

    rec.height = user_input_rec_height;
    rec.width = user_input_rec_width;
    System.out.println("The area of the rectangle is " +rec.area());
    System.out.println("-—————————");

    Triangle tri = new Triangle();
    System.out.println("Area of a Triangle");
    System.out.println(" <>");
    System.out.println(" [][]");
    System.out.println(" [] []");
    System.out.println(" [] []");
    System.out.println(" [] []");
    System.out.println(" [] []");
    System.out.println(" [][][][][][][]");
    System.out.println("Enter height of Triangle");
    Scanner scan2 = new Scanner(System.in);
    double user_input_tri_height = scan.nextDouble();

    System.out.println("Enter width of Triangle");
    Scanner scan3 = new Scanner(System.in);
    double user_input_tri_width = scan.nextDouble();

    tri.height = user_input_tri_height;
    tri.width = user_input_tri_width;
    System.out.println("The area of the rectangle is " +tri.area());

  35. Mohammed Kalache September 5, 2019 at 10:19 pm - Reply

    Thanks for the videos , very helpful , just few comments.

    your voice is not clear not only because the left earphone error , you're far away from Microphone or it's not a good one.

    Also you repeat your self many times. sometimes it's helpful and other times it's very irritating.

    hope this series will improve and show us real java not only methods and calculations.

    we haven't any interface or display window.

    But in total it's a very helpful series and thanks for uploading this and share with us your experiences

  36. Dinesh Sevalia September 5, 2019 at 10:19 pm - Reply

    There is some audio problem +ProgrammingKnowledge

  37. E Kennedy September 5, 2019 at 10:19 pm - Reply

    These turorials have been great.  Thanks for the time you seent doing them.

  38. mohit saraswat September 5, 2019 at 10:19 pm - Reply

    Please solve the sound problem. Otherwise the tutorials are awesome.

  39. sahej manchanda September 5, 2019 at 10:19 pm - Reply

    why did u use it can be done without set values may be we have to set 1 by 1 in main thatswhy

  40. BEERS 'n GEARS September 5, 2019 at 10:19 pm - Reply

    Do you hear the chirp sound every 37 seconds? Yes that is your smoke detector. It has a dead battery. Replace the battery…. jesus christ.

    Also, most of your video is in mono audio. What that means is that your voice only comes out of one speaker and static comes out of the other one. It is highly annoying, fix it.

  41. Angel Hadzhiev September 5, 2019 at 10:19 pm - Reply

    Bro i can tell you that you explain everything better than my professor 😀 i love your videos 🙂

  42. Mohammad Alam September 5, 2019 at 10:19 pm - Reply

    Tutorials are very good but some background noise, still it is free tutorial. 🙂

  43. ThatsRight September 5, 2019 at 10:19 pm - Reply

    U don't need to start with Protected… choose Private

Leave A Comment

*