- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Learn the Java super keyword in 10 minutes! 🔝
#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);
}
}
Видео Learn the Java super keyword in 10 minutes! 🔝 канала Bro Code
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);
}
}
Видео Learn the Java super keyword in 10 minutes! 🔝 канала Bro Code
Комментарии отсутствуют
Информация о видео
5 декабря 2024 г. 22:02:01
00:10:30
Другие видео канала




















