Lab 07
Lab 07
CMSID: 458118
Class: SE-14 B
Faculty of Computing
Inheritance Methods
2:00pm – 5:00 pm
Task 1:
Code:
public class Class {
int studentId;
Stirng name;
int age;
String course;
Class(String name){
this.name = name;
this.age = 20;
this.course = "OOP";
this.studentId = 458118;
}
Output:
Task 2:
Code:
public class BankAccount {
int accountNumber;
String accountHolderName;
int balance;
String accountType;
BankAccount(String accountHolderName){
this.accountHolderName = accountHolderName;
this.accountNumber = 456546;
this.accountType = "Current";
this.balance = 1000;
}
Output:
Task 3:
Code:
public class Animal {
String name;
Animal(String name){
this.name = name;
}
}
public static void main(String[] args){
dog myDog = new dog("Buddy", "Golder Retriever");
myDog.speak();
}
}
Output: