new Student(); System.out




Download 21,46 Kb.
bet6/6
Sana17.12.2023
Hajmi21,46 Kb.
#121647
1   2   3   4   5   6
Bog'liq
Java Class Methods1

new Student();

System.out.println("Name: " + myObj.fname);


System.out.println("Age: " + myObj.age);
System.out.println("Graduation Year: " + myObj.graduationYear);
myObj.study(); // call abstract method
}
}

Bu kod Main klassini abstrakt klass deb e'lon qiladi. Main klassida fname va age nomli xususiyatlar mavjud va study nomli abstract metod mavjud. Student klass esa Main klassidan meros olgan va study metodini uni o'z ichiga olgan subclass. Second klass esa Student klassini ishlatadi va uning obyektini yaratadi. Natijada, obyektning xususiyatlariga murojaat qilinadi va study metodini chaqiradi.
Download 21,46 Kb.
1   2   3   4   5   6




Download 21,46 Kb.