0% found this document useful (0 votes)
48 views

Sample Output Based Questions Java

The document discusses OOP concepts like inheritance, polymorphism and abstraction through examples of classes like Vehicle, Car, Audi, Bank, SBI, ICICI, AXIS etc. and their relationships. It also contains examples demonstrating overriding of methods and use of final keyword.

Uploaded by

akhtarwaheed902
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Sample Output Based Questions Java

The document discusses OOP concepts like inheritance, polymorphism and abstraction through examples of classes like Vehicle, Car, Audi, Bank, SBI, ICICI, AXIS etc. and their relationships. It also contains examples demonstrating overriding of methods and use of final keyword.

Uploaded by

akhtarwaheed902
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

OOP

Quiz#2
SapId:---------------
class Vehicle { class Bank{
public Vehicle() { int getRateOfInterest(){return 0;}
System.out.println("Vehicle"); }
} class SBI extends Bank{
} int getRateOfInterest(){return 8;}
class Car extends Vehicle { }
public Car() { class ICICI extends Bank{
System.out.println("Car"); int getRateOfInterest(){return 7;}
} } class Audi }
extends Car { class AXIS extends Bank{
public Audi() { int getRateOfInterest(){return 9;}
System.out.println("Audi"); }
} class Test2{
} public static void main(String args[]){
public class Main { SBI s=new SBI();
public static void main(String[] ICICI i=new ICICI();
args) { AXIS a=new AXIS();
Audi b = new Audi(); Bank b=new AXIS();
}} System.out.println("SBI Rate of
Interest: "+s.getRateOfInterest());
System.out.println("ICICI Rate of
Interest: "+i.getRateOfInterest());
Output: System.out.println("AXIS Rate of
Interest: "+a.getRateOfInterest());
System.out.println(" Rate of Interest:
"+b.getRateOfInterest());
}
}

Output:
class Bike9{ class Bike{
final int speedlimit=90;
void run(){ final void run(){System.out.println("running");}
speedlimit=400; }
} class Honda extends Bike{
public static void main(String void run(){System.out.println("running safely
args[]){ with 100kmph");}
Bike9 obj=new Bike9(); public static void main(String args[])
obj.run(); {
} Honda honda= new Honda();
} honda.run();
}}

Output: Output:

You might also like