Java Lab 2025_B.tech-4th Semester_Upto Array
Java Lab 2025_B.tech-4th Semester_Upto Array
B.TECH-4th Semester
COURSE OUTCOME:
Objective: The objective of this assignment is to learn how to write Simple JAVA Programs and
ideas about java data types, operators, condition checking and loops.
Objective: The objective of this assignment is to learn about Classes, Objects and Constructors.
1. Create a class Test, make instance variable [int x], method [void show()] and also put main method inside that
class and use the instance variable and method from main.
2. Create a class Test1, make instance variables [int x], method [void show()] and use them from main, declared
in different classes.
3. Create a class; put a method inside this class which will return a class reference of the same class and/or different
class object.
4. Write a JAVA Program to create a Student class with proper attributes like roll no, name, stream, and college.
Create two instances of that class from main (declared in different classes) and print them.
5. Design a class to represent a Bank Account. Include the following things:
Fields
● Name of the depositor
● Account number
● Type of account
● Balance amount in the account
Methods
● To assign initial values
● To deposit an amount
● To withdraw an amount after checking balance
● To display the name and balance
From main (declared in different classes) access them.
6. Do the problems 15 to 20 of Assignment-1 using the concept of class and object.
Objective: The objective of this assignment is to understand the concept of Polymorphism & Inheritance.
1. Write a java program to overload three methods named with addition() having different parameters.
2. Write a java program to overload the constructor named with Addition() having different parameters.
3. Overload the constructors for class Box for cube and cone and also display its volume.
5. Create a class Student containing instance variables roll and name and a parameterized constructor. Create
two objects of that class from the main class and print them (Hints: Override toString method of Object
class).
6. Create a class EMP having instance variable name and id. Create its subclass (say Scientist) which has instance
variable no_of_publication and experience. Now create its subclass, say Dscientist which has an instance
variable award. Put a method: public String toString () { } in every class where you describe about the class
and from the main create object of each class and print each object.
7. Create a class with a method void show () and make 3 subclasses of it and all subclasses have void show ()
method overridden and call those methods using their class references.
Objective: The objective of this assignment is to understand abstract methods, class and their uses.
1. Check without having any abstract method/s whether a class can be abstract; if so, then use that concrete
method/s from another class having the main method.
3. Write a Java Program to create a base class Animal having properties: consume food, capable of motion.
Two subclass Mammal and Reptile having features: covered with hairs and feed breast milk to its infants, can
crawl have scales and cold blooded respectively.
Show the properties of Human and cow for Mammal category, snake and crocodile for reptile category
adding one new feature for each of the classes.
4. Assume that a bank maintains two types of account for its customers, one called a savings account and other
called a current account. The savings account provides compound interest and withdrawal facilities but no cheque
book facility. The current account provides a check book facility but no interest. Current account holders should
also maintain a minimum balance (say Rs. 1000) and if the balance falls below this level a service charge is
imposed (say Rs. 100).
Create a class Account that stores customer name, account number and type of account. From this class
derive two classes Curr_Acct and Savn_Acct respectively to make them more specific to their requirements.
Include the necessary methods to achieve the following tasks:
a. Accept deposits from a customer and update the balance.
b. Display the balance.
c. Compute and deposit interest.
d. Permit withdrawal and update the balance.
e. Check for minimum balance, impose penalty, if necessary, and
update the balance. Use constructors to initialize the class members.