Java Program - Convert Temperatures
Java Program - Convert Temperatures
ROLL NO: 23
NAME: NIDHI SONI
1. Write Outer class Outer1 which include Static class StaticInner and non static inner
class NoStaticInner. Define variables in three classes. Demonstrate the access of all
variables
import java.util.Scanner;
{
// TODO Auto-generated method stub
}
class outer1
{
this.n=n;
}
public void display()
{
System.out.println("Number :"+n);
}
}
}
2. Create a student class with a name and id.
Each class has a show() method that displays the details of students' data.
import java.util.Scanner;
}
class student
{
int id,m1,m2,m3,sum;
String name;
double per,average ;
void add()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter Student Id:");
id=s.nextInt();
System.out.print("Enter Student Name:");
name=s.next();
}
}
void sub()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter Student Marks:");
m1=s.nextInt();
System.out.print("Enter Student Marks:");
m2=s.nextInt();
System.out.print("Enter Student Marks:");
m3=s.nextInt();
}
}
3. Create abstract class vehicle and define abstract as well as concrete method in this class. Inherit
this class into Car and Bike classes. Create a static method repair() in test class. Use this method to
repair either bike or car as per object passed.
import java.util.Scanner;
{
// TODO Auto-generated method stub
}
public static void repair(vehicle v1)
{
v1.honda();
v1.hero();
}