Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn the Java super keyword in 10 minutes! 🔝
Play lesson

Java tutorial for beginners ☕ - Learn the Java super keyword in 10 minutes! 🔝

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse public class Main { public static void main(String[] args) { // super = Refers to the parent class // Used in constructors and method overriding // Calls the parent constructor to initialize attributes Person person = new Person("Tom", "Riddle"); Student student = new Student("Harry", "Potter", 3.25); Employee employee = new Employee("Rubeus", "Hagrid", 50000); } } public class Person { String first; String last; Person(String first, String last){ this.first = first; this.last = last; } void showName(){ System.out.println(this.first + " " + this.last); } } public class Student extends Person{ double gpa; Student(String first, String last, double gpa){ super(first, last); this.gpa = gpa; } void showGPA(){ System.out.println(this.first + "'s gpa is: " + this.gpa); } } public class Employee extends Person{ int salary; Employee(String first, String last, int salary){ super(first, last); this.salary = salary; } void showSalary(){ System.out.println(this.first + "'s salary is $" + this.salary); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere