Java Lab File
Java Lab File
Java Lab File
INDEX
S.NO LAB SIGN REMARKS
NO.
1 LAB 01
2 LAB 02
3 LAB 03
4 LAB 04
5 LAB 05
6 LAB 06
7 LAB 07
8 LAB 08
--
LAB – 1
Program 1 :
Output :
LAB – 2
Program 1 :
Write a java program to design a point class with all the member functions as discussed in the
class. Explain the significance of this keyword
Output :
Program 2 :
Write a Java Program to Extend the Point Class to create Circle class with necessary members
functions.
Output :
LAB - 3
Program 1 :
Write a Java program to calculate the average value of array elements.
Output :
Program 2 :
Write a Java program to find the maximum and minimum value of an array.
Output :
Program 3 :
Write a Java program to find the duplicate values of an array of string values.
Output :
Program 4 :
Write a Java program to add two matrices of the same size.
Output :
LAB – 4
Program 1 :
Write a Java program that accepts two doubles as its command line arguments, multiply
these together and display the product.
Output :
Program 2 :
Write a Java program that accepts one command line argument; display the line of
reporting if number is even or odd.
Output :
Program 3 :
Write a Java program that accepts radius of a circle as its command line argument
display the area.
Output :
Program 4 :
Write a Java program that uses length property for displaying any number of command
line arguments.
Output :
Program 5 :
Write a Java program that describes a class person. It should have instance variables to
record name, age and salary. Create a person object. Set and display its instance
variables.
Output :
Program 6 :
Write a Java program computing the area of rectangle illustrating constructors.
Output :
LAB – 6
Program 1 :
Write a Java program to define a class MyNumber having one private int data
member. Write default constructor to initialize it to 0 and another constructor to
initialize it to a value (Use this for initialization). Write methods isNegative(),
isPositive(), isZero(), isOdd(), isEven(). Create an object in main(). Use Scanner
class to pass a value to the object.
Output :
Program 2 :
Write a Java program Define a Student class (roll number, name, percentage).
Define a default and parameterized constructor. Override the toString method.
Keep a count of objects created.
Create objects using parameterized constructor and display the object count after
each object is created. (Use static member and method). Also display the contents of
each object.
Output :
Program 3 :
Write a test program (say TestCylinder) to test the Cylinder class created. Create three
objects of Cylinder class namely c1,c2 and c3 as below and display height, radius, area and
volume of all the object
Program 2 :
Write a Java Program to implement the following class diagram.
Output :
LAB 8
Question 1:
List out the errors in above mentioned code if any. Correct them to run the program successfully.
Question 2:
Re-write the abstract superclass Shape into an interface, containing only abstract methods, as
follows:
Create a class TestShape as code of class is given below and predict the output.
public class TestShape { public static
void main(String[] args) {
Shape s1 = new Rectangle("red", 4, 5);
System.out.println(s1);
System.out.println("Area is " + s1.getArea());
List out the errors in above mentioned code if any. Correct them to run the program successfully.