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

All Java Code Lab1

The document contains Java code for a simple program that defines an 'Automobile' class and a subclass 'SUV'. The 'Automobile' class has attributes for make, model, year, and number of wheels, while the 'SUV' class adds passenger capacity and cargo space. The main method creates instances of both classes and calls their 'getinfo' methods, which are intended to print specific information about the vehicles.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

All Java Code Lab1

The document contains Java code for a simple program that defines an 'Automobile' class and a subclass 'SUV'. The 'Automobile' class has attributes for make, model, year, and number of wheels, while the 'SUV' class adds passenger capacity and cargo space. The main method creates instances of both classes and calls their 'getinfo' methods, which are intended to print specific information about the vehicles.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

public class Lab1

{
public static void main( String[] args )
{
Automobile a = new Automobile("Porsche", "911 ST", 2025, 4);
SUV s = new SUV("Subaru", "Outback", 2025, 4, 5, 6.7 );

a.getinfo();

s.getinfo();
}
}
//===================================================================

public class Automobile


{
private String make;
private String model;
private int year;
private int numWheels;

public Automobile(String mk, String md, int y, int nw)


{
make = mk;
model = md;
year = y;
numWheels = nw;
}

public void getinfo()


{
// print 'The programmer is: <your name>'
// print the 'Make: ' 'Model: ' 'Year: ' and 'Number of Wheels: '

}
}
//==================================================================

public class SUV extends Automobile


{
private int numpass;
private double cargospc;

public SUV(String mk, String md, int y, int nw, int np, double c)
{
//your code here (read instructions)
}

public void getinfo()


{
//your code here (read instructions)
}
}

You might also like