0% found this document useful (0 votes)
5 views5 pages

Java Lab Manual

The document outlines the lab planning for the Object Oriented Programming using Java course for B.Tech Batch 2024. It includes a detailed list of practical programs categorized by topics such as basic syntax, operators, data types, arrays, strings, object-oriented concepts, inheritance, abstract classes, interfaces, exception handling, multithreading, and I/O programming. Each practical session specifies the programs to be completed along with their respective categories and hours allocated.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Java Lab Manual

The document outlines the lab planning for the Object Oriented Programming using Java course for B.Tech Batch 2024. It includes a detailed list of practical programs categorized by topics such as basic syntax, operators, data types, arrays, strings, object-oriented concepts, inheritance, abstract classes, interfaces, exception handling, multithreading, and I/O programming. Each practical session specifies the programs to be completed along with their respective categories and hours allocated.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

2301CS201 - Object Oriented Programming using Java

B.Tech LAB PLANNING[BATCH 2024]

Lab Category No. Programs Hrs.


Practical -1:Java programs using basic syntax
A 1 JDK installation and configuration.[A]
A 2 Hello World Program using Java.[A]
A 3 Write a java program to take user input
i. through Command Line Argument.[A]
ii. through Scanner class.[A]
1 A 4 Write a program to get 2 numbers from the user and print the sum of two numbers 2
using command line and Scanner class.[A]
B 5 Write a program that reads a number in meters, converts it to feet, and displays the
result.[A]
C 6 Write a program that prompts the user to enter a letter and check whether a letter is a
vowel or a constant.[B]
Practical -2: Programs using operators and data types
A 1 Illustrate the Operator precedence.[A]
a. 10 + 20 * 30
b. 100 / 10 * 100
c. 5 * 4 / 4 % 3
d. 100 + 200 / 10 – 3 * 10
2
A 2 Write a program to create basic calculator by getting 2 numbers and 1 string (operation)
from the user and apply the operation given in a string on the given numbers.[A] 2
A 3 Write a program to calculate the area of Rectangle.[A]
B 4 Write a program to convert temperature from Fahrenheit to Celsius. (Formula : c = f-
32*5/9 );[B]
C 5 Write a program that prompts the user to enter three numbers. Find the largest
number.[C]
Practical -3: Programs using if-else ladders, conditional and branching statement
A 1 The marks obtained by a student in 5 different subjects are input through the
keyboard.
The student gets a division as per the following rules:
I. Percentage above or equals to 60-first division
II. Percentage between 50 to 59-second division
III. Percentage between 40 and 49-Third division
IV. Percentage less than 40-fail
Write a program to calculate the division obtained by the student.[A]
A 2 Write a program to check whether a number is even or odd.[A]
3 A 4 Write a program to find maximum no from given 3 no.(without if-else).[A]
2
A 5 Write a program to check that the given number is prime or not.[A]
B 6 Write a program to check whether a year is leap year or not.[B]
B 7 Write a program to find that given number is palindrome or not. [B]
C 8 Write a program to print prime numbers between given range. [C]

1
2301CS201 - Object Oriented Programming using Java
B.Tech LAB PLANNING[BATCH 2024]

Practical -4: Programs using Array and String (lab-1)


A 1 Write a program to accept a line and check how many consonants and vowels are there
in line.[A]
A 2 Write a program that creates and initializes a four integer element array. Calculate and
4 2
display the average of its values.[A]
A 3 Write a program to print given array in reverse order.[A]
B 4 Write a program to find length of string and print second half of the string.[B]
Practical -5: Programs using Array and String (lab-2)
A 5 Write an interactive program to print a string entered in a pyramid form. For instance,
the string "stream" has to be displayed as follows:[A]

s
st
str
stre
strea
stream
B 6 Write an interactive program to print a diamond shape. For example, if user enters
the number 3, the diamond will be as follows:[B]
*
**
***
**
5 2
*
C 7 There is an integer array nums sorted in ascending order (with distinct values).
Prior to being passed to your function, nums is possibly rotated at an unknown pivot
index k (1 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ...,
nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7]
might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].
Given the array nums after the possible rotation and an integer target, return the
index of target if it is in nums, or -1 if it is not in nums.[C]
Example 1:
Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4
Example 2:
Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1

Practical -6: Programs using Object Oriented Concepts


A 1 Write a program to create circle class with area function to find area of circle. [A]
A 2 Define Time class with constructor to initialize hour and minute. Also define addition
method to add two time objects. [A]
A 4 Create a class named Bank_Account with data memebers accountNo, userName, email,
6 accountType and accountBalance, Also create methods getAccountDetails() and 2
displayAccountDetails(). [A]
B 3 Create a class which ask the user to enter a sentence, and it should display count of
each vowel type in the sentence. The program should continue till user enters a word
“quit”. Display the total count of each vowel for all sentences. [B]

2
2301CS201 - Object Oriented Programming using Java
B.Tech LAB PLANNING[BATCH 2024]

B 5 Define class for Complex number with real and imaginary as data members. Create its
constructor, overload the constructors. Also define addition method to add two
complex objects. [B]
B 6 WAP that counts the number of objects created using static. [B]
C 7 Write a program in Java to demonstrate use of this keyword. Check whether this can
access the Static variables of the class or not.[C]
Practical -7: Programs using inheritance
A 1 Declare a class called Student having following data members:id_no,
no_of_subjects_registered, subject_code, subject_credits, grade_obtained and spi.
Define constructor and calculate_spi methods. Define main to instantiate an array for
objects of class student to process data of n students to be given as command line
arguments. [A]
A 2 Declare a class called book having author_name as private data member. Extend book
class to have two sub classes called book_publication & paper_publication. Each of
these classes have private member called title. Write a complete program to show
usage of dynamic method dispatch (dynamic polymorphism) to display book or paper
publications of given author.Use command line arguments for input data. [A]
A 4 Demonstrate the use of Super Keyword. [A]
A 5 Demonstrate the use of Final Keyword. [A]
B 3 Create a class named 'Member' having the following members:
1-Name
2-Age
3-Phone number
4-Address
5-Salary
It also has a method named 'printSalary' which prints the salary of the members.
Two classes 'Employee' and Manager' inherits the 'Member' class. The 'Employee' and
7 'Manager' classes have data members 'specialization' and 'department' respectively.
Now assign name, age, phone number address and salary to an employee and a 2
manager by making an object of both of these classes and print the same along with
specialization and department respectively. [B]
C 6 4. Design a class named MyPoint to represent a point with x- and y-coordinates. The
class contains:
The data fields x and y that represent the coordinates with getter methods.
1. a no-arg constructor that creates a point (0, 0).
2. a constructor that constructs a point with specified coordinates.
3. a method named distance that returns the distance from this point to a specified
point of the MyPoint type.
4. a method named distance that returns the distance from this point to another point
with specified x- and y-coordinates.Create a class named ThreeDPoint to model a
point in a three-dimensional space. Let ThreeDPoint be derived from MyPoint with
following additional features:
1. A data fields named z that represents the z-coordinate.
2. A no-arg constructor that creates a point (0, 0, 0).
3. A constructor that constructs a point with three specified coordinates.
4. A get method that returns the z value.
5. Override the distance method to return the distance between two points in the
three-dimensional space. Write a program that creates two points (0, 0, 0) and (10,
30, 25.5) and display the distance between the two points. [C]

3
2301CS201 - Object Oriented Programming using Java
B.Tech LAB PLANNING[BATCH 2024]

Practical -8: Programs using abstract class and interface (lab-1)


A 1 The abstract vegetable class has three subclasses named Potato, Brinjal and Tomato.
Write a java program that demonstrates how to establish this class hierarchy. Declare
one instance variable of type String that indicates the color of a vegetable. Crete and
display instances of these objects. Override the toString() method of object to return a
string with the name of vegetable and its color. [A]
A 2 Write a program that illustrates interface inheritance. Interface A is extended by A1 and
8 A2. Interface A12 inherits from both A1 and A2.Each interface declares one constant 2
and one method. Class B implements A12.Instantiate B and invoke each of its methods.
Each method displays one of the constants. [A]
A 3 The Transport interface declares a deliver () method. The abstract class Animal is the
super class of the Tiger, Camel, Deer and Donkey classes. The Transport interface is
implemented by the Camel and Donkey classes. Write a test program that initialize an
array of four Animal objects. If the object implements the Transport interface, the
deliver () method is invoked. [A]
Practical -9: Programs using abstract class and interface (lab-2)
A 4 Create interface EventListener with performEvent() method. Create MouseListener
interface which inherits EventListener along with mouseClicked(), mousePressed(),
mouseReleased(), mouseMoved(), mouseDragged() methods. Also create KeyListener
interface which inherits EventListener along with keyPressed(), keyReleased() methods.
WAP to create EventDemo class which implements MouseListener and KeyListener and
demonstrate all the methods of the interfaces. [A]
B 5 Write a Java program to create an interface Shape with the getArea() method. Create
9 three classes Rectangle, Circle, and Triangle that implement the Shape interface. 2
Implement the getArea() method for each of the three classes. [B]
C 6 Write a Java program to create an interface Playable with a method play() that takes no
arguments and returns void. Create three classes Football, Volleyball, and Basketball
that implement the Playable interface and override the play() method to play the
respective sports. [C]

Practical -10: Programs using Exception handling


A 1 Write a program to demonstrate Arithmetic Exception and ArrayIndexOutOfBounds
Exception using try-catch block. [A]
A 2 Write a program to create Account class, which is representing a bank account where
we can deposit and withdraw money. If user need to withdraw money which exceed
our minimum bank balance then it will not be allowed, and will throw
InSufficientFundException(Custom Exception). Handle above exception and display
proper error message. [A]
A 3 Write a java program to create Custom Exception ( DarshanUniException). Catch this
10 exception using throw clause and print appropriate message. [A] 2
B 4 Write a Java program that divides two numbers. If Num1 or Num2 were not an integer,
the program would throw a Number Format Exception. If Num2 were Zero, the program
would throw an Arithmetic Exception. Display appropriate message for each exception.
[B]
C 5 Write a program in java if number is less than 10 and greater than 50, it generate the
exception out of range. Else it displays the square of number. [C]

4
2301CS201 - Object Oriented Programming using Java
B.Tech LAB PLANNING[BATCH 2024]

Practical -11: Programs using Multithreading


A 1 Write a java Multithread program [A]
i. Using Thread class.
ii. Using Runnable Interface.
A 2 Write an application that executes two threads. One thread displays "Good Morning"
every 1000 milliseconds & another thread displays "Good Afternoon" every 3000
milliseconds. Create the threads by implementing the Runnable interface. [A]
A 3 WAP to implement the solution to producer consumer problem in Java. [A]
B 4 Write a program to create two threads, one thread will print odd numbers and second
thread will print even numbers between 1 to 20 numbers. [B]
B 5 Write a java program that implements a multi-thread application that has
11 2
three threads. First thread generates random integer every 1 second and if
the value is even, second thread computes the square of the number and
prints. If the value is odd, the third thread will print the value of cube of
the number. [B]
C 6 Write a complete multi-threaded program to meet following requirements:
a. Read matrix [A] m x n
b. Create m number of threads
c. Each thread computes summation of elements of one row, i.e. ith row of the matrix
is processed by ith thread. Where 0 <= i< m.
d. Print the results. [C]
Practical -12: Basic programs using IO programming
A 1 Write a program that counts number of characters, words, and lines in a file. Use
exceptions to check whether the file that is read exists or not. [A]
A 2 Write a program to replace all “word1” by “word2” from a file1, and output is written
to file2 file and display the no. of replacement. [A]
12 B 3 Write an application that reads a file and counts the number of occurrences of digit 5. 2
Supply the file name as a command-line argument. [B]
C 4 Create a class called Student. Write a student manager program to manipulate the
student information from files by using FileInputStream and FileOutputStream. [C]

Practical -13: Advanced programs using IO programming and Collection Framework


A 1 Refine the student manager program to manipulate the student information from files
by using the BufferedReader and BufferedWriter. [A]
A 2 Write a program of writing binary file using multithreading. Demonstrate use of join()
and yield() interrupt(). [A]
B 3 Write a program to check that whether the name given from command line is file or
not? If it is a file then print the size of file and if it is directory then it should display the 2
13 name of all files in it. [B]
C 4
Refine the student manager program to manipulate the student information from files
by using the DataInputStream and DataOutputStream. Assume suitable data. [C]
C 5 Write a program to demonstrate the use of ArrayList to store and display List of Student
class with StudentID, StudentName, StudentRollNo and StudentSPI. [C]
C 6 Write a program to sort as per SPI from the List of students stored as ArrayList in
previous program. [C]

You might also like