You are on page 1of 2

Practical no.

17

Q1. class bank


{
int interest()
{
return(9);
}
}
class icic extends bank
{
int interest()
{
return(11);
}
}
class axis extends bank
{
int interest()
{
return(14);
}
}
class sbi extends bank
{
int interest()
{
return(8);
}
}
class methodoverriding
{
public static void main(String args[])
{
icic c=new icic();
axis a=new axis();
sbi s=new sbi();
System.out.println("Rate of interest of banks");

System.out.println("Rate of interest of icic bank="+c.interest());


System.out.println("Rate of interest of axis bank="+a.interest());
System.out.println("Rate of interest of sbi bank="+s.interest());
}
}
Q2. import java.util.Scanner;
class student
{
Scanner s=new Scanner(System.in);
int rno;
String name;

void get()
{
System.out.println("Enter roll no");
rno=s.nextInt();
System.out.println("Enter Name");
name=s.next();
}
void display()
{
System.out.println("Roll no="+rno);
System.out.println("Name"+name);
}

class marks extends student


{
Scanner s=new Scanner(System.in);
int m1,m2;

void get()
{super.get();
System.out.println("Enter marks of 1st sub");
m1=s.nextInt();
System.out.println("Enter marks of 2nd sub");
m2=s.nextInt();
}

void display()
{super.display();
System.out.println("Marks of sub 1="+m1);
System.out.println("Marks of sub 2="+m2);
}

public static void main(String args[])


{
marks m=new marks();
System.out.println("Details of Student");

m.get();
m.display();
System.out.println(" ");
m.get();
m.display(); }}

You might also like