Module 1: Introduction to Java (3 Hours)
Java Introduction and History.
Java Development Kit (JDK), Java Runtime Environment (JRE), and Java Virtual
Machine (JVM).
First Java Program Structure.
Data Types and Variables.
Operators and Expressions.
Type Casting and Conversion.
Input and Output in Java.
Hands-On Practice
1. Write a Java program to declare different types of variables (int, float, double, char,
boolean, etc.) and display their default values.
2. Write a Java program to store your name, age, and grade in variables, then print them
using appropriate data types.
3. Write a Java program to calculate the sum and product of two int values and display
the result.
4. Write a Java program to swap two numbers using a temporary variable.
5. Write a Java program to find the area and perimeter of a rectangle using float data
types.
6. Write a Java program to find the volume of a cylinder given radius and height.
7. Write a Java program that uses boolean to check if a given number is positive or
negative.
8. Write a Java program to demonstrate the use of arithmetic operators by performing
addition, subtraction, multiplication, division, and modulus operations on two
numbers.
9. Write a Java program to calculate the average of three numbers using expressions and
operators.
10. Write a Java program to find the square and cube of a number using the * operator.
11. Write a Java program to use relational operators to compare two numbers and display
if one is greater, less than, or equal to the other.
12. Write a Java program to check if a number is even or odd using the modulus
operator.
13. Write a Java program to demonstrate the use of increment (++) and decrement (--)
operators.
14. Write a Java program to demonstrate logical operators (&&, ||, !) by checking
conditions such as "Is a number between 10 and 20?"
15. Write a Java program to demonstrate implicit (automatic) type conversion by
assigning an int to a double variable.
16. Write a Java program to demonstrate explicit (manual) type casting by converting a
double value to an int.
17. Write a Java program to convert a float to an int and display both values.
18. Write a Java program that reads a number as a double and casts it to int, then prints
both values to show the difference in precision.
19. Write a Java program to convert a char (character) to its corresponding ASCII value
using type casting.
20. Write a Java program to take an int value as input and convert it to a string.
21. Write a Java program to convert a string to a float and perform a multiplication on it.
22. Write a Java program that takes two numbers as input from the user using the
Scanner class and prints their sum.
23. Write a Java program to take input of a user's name and age and print a greeting
message using the entered values.
24. Write a Java program to calculate the area of a circle by taking the radius as input
from the user.
25. Write a Java program to take a number as input and display its square and cube using
input-output operations.
26. Write a Java program to read two numbers using the Scanner class, perform
arithmetic operations (addition, subtraction, multiplication, and division), and print
the results.
27. Write a Java program to take a user's height in meters and weight in kilograms, then
calculate and print their Body Mass Index (BMI).
28. Write a Java program to take input of a student's marks in five subjects and calculate
their total and percentage.
Module 2: Control Structures (3 hours)
Conditionals: if, else if, else, switch-case
Loops: for, while, do-while
Break, Continue, Return Statements
Enhanced for loop
Hands-On Practice
1. Write a Java program to accept a student’s marks (0–100) and print the grade (A, B,
C, D, F) using a switch statement.
2. Write a Java program using a for loop to find the sum of the first 10 natural numbers.
3. Write a Java program to print the multiplication table of a given number using a for
loop.
4. Write a Java program to calculate the factorial of a given number using a for loop.
5. Write a Java program that reverses the digits of a number using a while loop.
6. Write a Java program to check whether a given number is a palindrome using a while
loop.
7. Write a Java program to calculate the sum of the digits of a number using a while
loop.
8. Write a Java program using a do-while loop to repeatedly take input until a negative
number is entered and calculate the sum of positive numbers.
9. Write a program that generates a random number and asks the user to guess the
number using a do-while loop. The loop continues until the correct guess is made.
10. Write a Java program using a do-while loop to display a menu with options (e.g.,
calculator operations, conversion tools) and repeat until the user chooses to exit.
11. Write a Java program to find the first prime number between 50 and 100 using a for
loop and break statement.
12. Write a program where the user enters numbers repeatedly. If the number 0 is entered,
the program should stop (use break).
13. Write a Java program using a for loop to print numbers from 1 to 20, skipping
multiples of 3 using the continue statement.
14. Write a Java program to print only odd numbers between 1 and 20 using the continue
statement in a for loop.
15. Write a Java program to print a pyramid of numbers as below pattern using nested
loops.
1
121
12321
1234321
16. Write a Java program to print multiplication tables from 1 to 5 using nested loops.
17. Write a Java program using nested loops to print all prime numbers between 1 and 50.
18. Write a Java program to print the following star pattern using nested loops:
*****
****
***
**
*
19. Write a Java program to add two 3x3 matrices using nested loops.
Module 3: Object-Oriented Programming (6 Hours)
Introduction to OOP Concepts: Objects, Classes, Methods
Encapsulation, Inheritance, Polymorphism, and Abstraction
Constructors: Default and Parameterized
this Keyword
Method Overloading
Hands-On Practice
1. Write a Java program to create a class called Person with properties like name, age,
and a method displayDetails() to print these details. Create an object of the class
and call the method.
2. Implement a Java program to demonstrate the concept of a method by creating a class
Calculator with methods to add, subtract, multiply, and divide two numbers.
3. Write a Java program to create a class called Car with instance variables for brand,
model, and a method startEngine(). Create multiple objects for different car
models and invoke the method.
4. Design a Java program to create a class Student that contains instance variables for
storing a student’s ID, name, and grade, and a method showInfo() to display the
student details.
5. Write a Java program to implement a class Book with instance variables for the title,
author, and price. Create objects for three different books and display their details
using a method.
6. Create a Java program to implement a class Employee with private variables empID,
name, and salary. Use getter and setter methods to access and modify these fields.
7. Write a Java program where a class Dog inherits from a superclass Animal. The
Animal class has a method makeSound(), and the Dog class overrides it to print a
barking sound.
8. Write a Java program to demonstrate method overriding using a superclass Shape
with a method draw() and two subclasses Circle and Rectangle that provide their
own implementation of draw().
9. Implement a Java program where an abstract class Vehicle has an abstract method
startEngine(). Create two subclasses Car and Motorcycle to provide their own
specific implementations of startEngine().
10. Design a program to model a BankAccount class with private attributes like balance
and public methods like deposit(), withdraw(). Create a subclass SavingsAccount
and CheckingAccount that inherit from BankAccount.
11. Write a Java program to demonstrate a default constructor. Create a class Product
that has a default constructor to initialize values for product details and a method to
display them.
12. Implement a Java program to demonstrate parameterized constructors by creating a
class Person with a constructor that takes name, age, and address as parameters.
Instantiate objects using this constructor and display the details.
13. Create a Java class Book with default and parameterized constructors. The
parameterized constructor should initialize the title, author, and price. Write a method
to display book details.
14. Write a Java program that creates a class Employee with instance variables for name
and salary. Create a default constructor to initialize the name as "Unknown" and
salary as 0. Provide a parameterized constructor to initialize with specific values.
15. Develop a Java program where a class Student uses a parameterized constructor to
take name, rollNo, and marks as input. Write a default constructor to initialize
default values and demonstrate constructor overloading.
16. Write a Java program to create a class Rectangle that has a constructor with
parameters length and width. Use the this keyword to distinguish between instance
variables and constructor parameters.
17. Create a Java program where a class Person has instance variables name and age.
Use the this keyword to resolve the conflict between instance variables and
constructor parameters when initializing them.
18. Write a Java program to create a class Car with attributes brand, model, and price.
Use the this keyword to refer to the current object within a method that updates the
price of the car.
19. Implement a Java program to demonstrate the use of the this keyword to call another
constructor within the same class. Create a Student class with two constructors (one
with and one without parameters).
20. Design a Java program where a method in the Employee class passes the current
object using the this keyword to another method.
21. Write a Java program to demonstrate method overloading by creating a Calculator
class with methods add(int a, int b) and add(int a, int b, int c). Show
how method overloading works with different numbers of arguments.
22. Implement a Java program to overload the area() method in a class Shape to
calculate the area of a circle, rectangle, and triangle based on different parameter sets.
23. Create a Java class MathOperations with overloaded methods multiply(int,
int), multiply(double, double), and multiply(int, int, int) to demonstrate
method overloading by changing parameter types and numbers.
24. Write a Java program to create a class Person with an overloaded method
showInfo(). The method should be overloaded to display different details based on
different input parameters such as name, age, and address.
25. Design a Java program to overload a print() method in a class Display that accepts
different types of arguments like String, int, and double, and prints them.
Module 4: Arrays and Strings (5 Hours)
Array Basics: Single & Multidimensional Arrays
Array Operations
Introduction to String: String, StringBuffer, StringBuilder
String Manipulation: Methods in String class
Hands-On Practice
1. Write a Java program to create a single-dimensional array of integers. Initialize the
array with 5 numbers and display the elements using a for loop.
2. Write a Java program that allows the user to input 10 integers into a single-
dimensional array and print them in reverse order.
3. Create a Java program to initialize a 2x2 matrix and display its elements using nested
loops.
4. Write a Java program that takes input for a 3x3 matrix from the user and prints the
sum of all elements.
5. Write a Java program to create a 3x3 matrix and print the elements on the diagonal.
6. Write a Java program to input two 2x2 matrices and perform matrix addition. Print
the resulting matrix.
7. Write a Java program to create an array of integers and find the largest and smallest
elements in the array.
8. Write a Java program that implements a linear search on a single-dimensional array to
search for an element entered by the user.
9. Write a Java program to sort an array of integers in ascending order using the bubble
sort algorithm.
10. Write a Java program that copies elements from one array to another using array
assignment and displays the copied array.
11. Write a Java program to count the frequency of each element in a single-dimensional
array.
12. Write a Java program that removes duplicate elements from an array and displays the
array without duplicates.
13. Write a Java program to declare a string, initialize it with a value, and print the string.
14. Write a Java program to compare the performance of StringBuffer and StringBuilder
by concatenating 1000 characters and measuring the time taken.
15. Write a Java program to reverse a string using the StringBuffer class.
16. Write a Java program that uses the StringBuilder class to append and insert characters
in a string.
17. Write a Java program that demonstrates the difference between string concatenation
using the + operator and using the concat() method.
18. Write a Java program to calculate the length of a string and print each character of the
string using charAt() method.
19. Write a Java program to find and extract a substring from a given string using the
substring() method.
20. Write a Java program that converts a given string to uppercase and lowercase using
the toUpperCase() and toLowerCase() methods.
21. Write a Java program to count the number of occurrences of a specific character in a
string using the charAt() method.
22. Write a Java program to compare two strings using the equals() and
equalsIgnoreCase() methods.
23. Write a Java program to replace all occurrences of a particular character in a string
using the replace() method.
24. Write a Java program that splits a given sentence into words using the split() method
and prints each word.
Assignments
1. Develop an application to manage Student information, including enrolment, grades,
and attendance.
Operations :
To set and get rollno, name and branch
To read 5 subject marks and calculate percentage
To display complete data of a student
2. Develop a system to manage an inventory of products with below given
specifications.
Operations :
To set and get productid, name, quantity, price
Search by productid
3. Develop a system to manage a library of books with below given specifications
Operations :
To set and get bookid, name, author, quantity, price
Search by bookid
To list all books
4. Develop a simple banking system with below given specifications.]
Operations :
To set and get accnumber, name, balance, type
To deposit and withdraw
Search by accountnumber
5. Develop a system to manage restaurant orders with below given specifications.]
Operations :
To add and delete menu item along with price
To view all menu items
To place order and view total price
Module 5: Java Package
Introduction to Package
Types of Packages
Defining, Creating and Accessing a Package
importing packages
Hands-On Practice
1. Define a package named mypackage and include a class HelloWorld inside it with a
method to print "Hello, World!". Write a program to import and call this class from
another file.
2. Write two classes, ClassA and ClassB, without defining any package. Show how Java
treats classes that do not belong to any explicit package (default package).
3. Create two packages, package1 and package2, and define a class Employee in both
packages with the same method name display(). Demonstrate how using different
package names prevents name conflicts.
4. Create a package utilities, place it in a specific directory, and demonstrate how to compile
and run the Java program by setting the classpath using the -cp or CLASSPATH
environment variable.
5. Write a program that makes use of Java's built-in packages like [Link] and
[Link]. Use methods from these classes to add elements to an ArrayList and create a
file on the system.
6. Create a package named calculations and define a class Calculator inside it. Write
methods for addition, subtraction, multiplication, and division. Write another program
that imports this package and demonstrates its usage.
7. Write a program that uses classes from the [Link] package, such as HashMap, List, and
Collections, to perform operations on a list of items and sort them.
8. Create a package school with a subpackage students. In students, define a class Student
with methods to get and display student information. Import and use the class from the
subpackage.
9. Create two packages: mathematics and statistics. In mathematics, create a class
BasicOperations with methods for addition and subtraction, and in statistics, create a
class Average with a method to calculate the average of numbers. Write a program that
imports and uses both packages.
10. Create a package vehicle with a class Car that contains properties like model, price, and
engineType. Write methods to set and get these properties, and access the package in a
different class to demonstrate encapsulation.
11. Create a main package commerce with subpackages [Link] and
[Link]. In sales, create a class SalesReport and in products, create a class
Product. Demonstrate the hierarchy of packages and how to access them.
12. Define a package library and include two classes: Book and LibraryCard. The Book class
should contain details of books, and LibraryCard should contain user information. Show
how multiple classes can be accessed from the same package.
13. Create a package university and define two classes: one PublicClass with public access
and another DefaultClass with default access. Show how access specifiers affect package-
level accessibility.
14. Create a package animals that contains an interface Animal with methods like eat() and
move(). Define classes Dog and Cat that implement this interface. Import and access the
package to demonstrate polymorphism through interfaces.
15. Create a package mathutils with a class MathFunctions that provides methods for power
and square root. Import only the MathFunctions class into another program and
demonstrate its use.
16. Create a package games that contains multiple classes like Chess, Football, and
Basketball. Import the entire games package into another program and demonstrate
accessing different classes from it.
17. Create a class Constants inside a package utils that defines some static final constants like
PI, E. Use static import to import these constants in another class and perform
mathematical calculations without qualifying the class name.
18. Define a class Employee in a package company. Without importing the package, write a
program that uses the fully qualified name (e.g., [Link]) to create objects
and access members of the class.
19. Create two packages package1 and package2, both containing a class Employee.
Demonstrate how to import both classes in the same program by using fully qualified
names to differentiate between them.
20. Define a package finance and create a class LoanCalculator that calculates simple and
compound interest. Import this package into another class and perform calculations for a loan.
21. Create a package university with classes Student, Course, and Enrollment. Write
methods for student enrollment in courses and display details. Implement the package in
another program.
22. Create a package conversion with a class TemperatureConverter to convert between
Celsius and Fahrenheit. Use this package in two different programs to demonstrate code reuse.
23. Create two packages: sports and academics. In sports, define a class SportsEvent with
event details, and in academics, define a class Exam. Write a main program to organize student
participation in both events and exams using these packages.
24. Create a main package technology with subpackages hardware and software. In
hardware, define a class Computer, and in software, define a class OperatingSystem.
Import and use these classes in a program that models a computer system.
Module 6: Inheritance and Polymorphism
Types of Inheritance
Super Keyword
Method Overriding
Dynamic Method Dispatch
final Keyword
Hands-On Practice
1. Create a base class Animal with properties like name and methods like eat(). Derive a
subclass Dog that adds a method bark(). Write a program to demonstrate single
inheritance by creating objects of the Dog class.
2. Create a base class Vehicle with methods like startEngine(). Derive a subclass Car that
adds more functionality. Further derive a class ElectricCar from Car that introduces
electric-specific functionality. Demonstrate multilevel inheritance by creating objects of
ElectricCar.
3. Create a base class Person with properties like name and age. Derive two classes Student
and Teacher from Person, adding specific methods in each. Demonstrate hierarchical
inheritance by creating objects of Student and Teacher.
4. Create an interface Vehicle with methods drive() and stop(). Implement this interface in
two classes: Car and Bike. Then, derive a class HybridCar that extends both Car and
implements Vehicle to show hybrid
5. Create two interfaces, Playable (with a method play()) and Recordable (with a method
record()). Create a class Media that implements both interfaces and demonstrates multiple
inheritance by overriding both methods in the class.
6. Create a base class Person with a constructor that initializes name. Create a subclass
Employee that adds salary. Use the super() keyword to call the constructor of the Person
class and initialize name.
7. Create a base class Vehicle with a method start(). Create a subclass Car that overrides the
start() method but also calls the superclass method using the super keyword. Demonstrate
both the base and subclass versions of the method being executed.
8. Define a class Animal with a variable type. Derive a class Dog that has its own variable
type. Use the super keyword to access the superclass variable and demonstrate how both
variables are used.
9. Create a base class Shape with a method draw() that prints "Drawing Shape". In a
subclass Circle, override the draw() method and use [Link]() to call the parent class
version as well. Show how both the parent and child methods are called.
10. Create a base class A with a method display(). Derive a class B that overrides display(),
and then further derive a class C from B. Use super in class C to call the display() method
from both class B and A.
11. Create a base class Employee with a method getDetails() that prints employee details.
Derive a subclass Manager that overrides getDetails() to include additional information.
Create objects of both classes and demonstrate method overriding.
12. Define a base class Shape with a method draw(). Create two subclasses Circle and
Rectangle that override the draw() method. Write a program that uses polymorphism to
call draw() for different types of shapes.
13. Create a class Parent with a constructor and a method display(). Create a subclass Child
that overrides display(). Write a program that shows the order of constructor calls and
method overriding when creating an object of Child.
14. Create a base class Library with a method issueBook() that has protected access. Derive a
subclass PublicLibrary and override issueBook() with public access. Demonstrate that
overriding can increase visibility.
15. Create a base class Car with a final method startEngine(). Derive a subclass ElectricCar
and attempt to override startEngine(). Write a program to show that the compiler will
prevent overriding of a final method.
16. Create a base class Phone with a method call(). Derive two subclasses Smartphone and
Landline that override the call() method. Use dynamic method dispatch to create a
reference of type Phone and point it to Smartphone and Landline objects. Demonstrate
runtime polymorphism.
17. Create a class Animal with a method sound(). Create subclasses Dog and Cat that
override the sound() method. Write a program to demonstrate dynamic method dispatch
by calling sound() on Animal references pointing to different subclass objects.
18. Create an interface Shape with a method draw(). Implement the interface in two classes,
Circle and Triangle. Use dynamic method dispatch to invoke draw() on objects of Circle
and Triangle at runtime.
19. Create a base class Vehicle with a method drive(). Derive two classes Car and Bike that
override the drive() method. Demonstrate how casting from base class references to
subclass references affects dynamic method dispatch.
20. Create a class Shape with a method draw(). Derive subclasses Circle, Square, and
Triangle, each overriding the draw() method. Create an array of Shape references and
dynamically assign different subclass objects to it. Call the draw() method for each object
in the array.
21. Create a class Circle with a final variable PI. Show how to initialize the variable either
directly or through a constructor. Write a program to demonstrate that final variables
cannot be changed after initialization.
22. Create a base class Employee with a final method getSalary(). Attempt to override this
method in a subclass Manager and demonstrate how the final method prevents
overriding.
23. Create a final class BankAccount that contains methods for deposit and withdrawal.
Attempt to inherit from BankAccount in a subclass SavingsAccount and demonstrate that
inheritance from a final class is not allowed.
24. Create a class MathOperations with a method multiply(final int a, int b). Inside the
method, attempt to modify the final parameter and demonstrate that a final parameter
cannot be changed.
25. Create a class Constants with a final static variable MAX_VALUE. Show that
MAX_VALUE is a constant and demonstrate its use in a separate class that accesses it
without creating an instance of Constants.
Module 7: Exception Handling (4 Hours)
Introduction to Exceptions
Types of Exceptions
try, catch, finally, throw, throws
Custom Exceptions
Hands-On Practice
1. Write a Java program that divides two numbers. Use exception handling to manage a
scenario where the denominator is zero.
2. Create a Java program that reads an integer from the user and handles the
InputMismatchException when the user inputs non-integer data.
3. Develop a Java program to access an element in an array. Handle the case when the user
attempts to access an index that is out of bounds.
4. Write a Java program to perform file reading. Use exception handling to manage the case
when the file is not found.
5. Implement a Java program that performs type casting. Handle the case where a
ClassCastException might be thrown.
6. Write a Java program to handle both ArithmeticException and
ArrayIndexOutOfBoundsException in the same program.
7. Create a Java program that demonstrates the difference between checked and unchecked
exceptions by implementing file handling (checked) and a simple division (unchecked)
operation.
8. Write a program that shows the hierarchy of exceptions by catching both Exception and
RuntimeException in separate catch blocks.
9. Develop a Java program where you create an array of integers, iterate through it, and
throw an ArrayStoreException when attempting to store a different data type.
10. Implement a Java program that reads a file and handles exceptions like
FileNotFoundException (checked) and NullPointerException (unchecked).
11. Write a Java program to demonstrate the use of try, catch, and finally blocks by reading
from a file. Make sure the file is closed in the finally block.
12. Create a Java program that uses the throw keyword to manually throw an
IllegalArgumentException when invalid data is passed.
13. Write a program that demonstrates how the throws keyword is used to declare an
exception in the method signature (for example, reading from a file or performing
division).
14. Implement a Java program where you handle an exception in the catch block, but
regardless of the outcome, you execute the finally block for resource cleanup.
15. Write a program that demonstrates using try-catch for exception handling but with throw
to re-throw the caught exception after logging it.
16. Create a custom exception called AgeInvalidException that gets thrown if the age entered
by the user is less than 18. Write a program that uses this exception.
17. Write a Java program to create a custom exception named NegativeBalanceException.
Throw this exception if a bank account balance goes below zero.
18. Develop a program to create a custom exception InvalidSalaryException, which is thrown
when the entered salary is negative or too high. Handle this exception appropriately.
19. Implement a custom exception InvalidGradeException that gets thrown when a student's
grade is outside the A-F range. Write a program to handle this exception.
20. Write a program that creates a custom exception called InsufficientFundsException.
Throw this exception when a user tries to withdraw more money than is available in their
bank account.
Module 8: Interfaces and Abstract Classes )
Difference Between Abstract Classes and Interfaces
Defining and Implementing Interfaces
Multiple Inheritance via Interface
Hands-On Practice
1. Write a Java program that demonstrates the difference between an abstract class and an
interface by creating an abstract class Animal with a method makeSound() and an
interface Pet with a method play(). Implement both in a class Dog.
2. Create a Java program with an abstract class Vehicle that has a method startEngine().
Also, create an interface ElectricVehicle with a method chargeBattery(). Implement both
in a class TeslaCar. Show how abstract classes can have both abstract and non-abstract
methods, while interfaces cannot.
3. Implement a Java program to demonstrate that abstract classes can have constructors and
member variables, but interfaces cannot. Create an abstract class Shape with a constructor
that initializes the color and an interface Resizable that declares a method resize().
4. Write a Java program that shows how multiple inheritance is not possible with abstract
classes but is possible with interfaces by creating two abstract classes and two interfaces,
and then attempting multiple inheritance.
5. Create a program that explains the difference between default methods in interfaces and
methods in abstract classes. Use a default method in an interface and a regular method in
an abstract class, then implement both in a concrete class.
6. Write a Java program to create an interface Printable with a method print(). Implement
this interface in two classes Document and Image. Demonstrate how both classes
implement the same method in different ways.
7. Develop a Java program that creates an interface Payment with a method
processPayment(). Implement this interface in two classes: CreditCardPayment and
PaypalPayment. Demonstrate polymorphism using this interface.
8. Implement a Java program to define an interface Flyable with a method fly(). Create two
classes Bird and Airplane, which implement Flyable. Create objects of both classes and
call the fly() method to show how interfaces work.
9. Write a Java program that defines an interface Calculator with methods add, subtract,
multiply, and divide. Implement the interface in a class BasicCalculator and write a test
program to use this interface.
10. Create a Java program with an interface Drivable having a method drive(). Implement
this interface in three classes: Car, Bike, and Truck. Use the Drivable interface reference
to call the drive() method on objects of different classes.
11. Write a Java program to demonstrate multiple inheritance by creating two interfaces
Workable and Playable, each with a method. Implement both interfaces in a class Human
and show how the class can inherit methods from both interfaces.
12. Create a Java program that defines two interfaces Flyable and Swimmable, each having a
method fly() and swim(). Implement both interfaces in a class Duck to demonstrate
multiple inheritance.
13. Develop a Java program to demonstrate the scenario where two interfaces have a method
with the same name. Create two interfaces Soundable and Ringable, both with a method
makeSound(). Implement both in a class Phone. Show how to resolve method ambiguity
using default methods or overriding.
14. Write a Java program where you create two interfaces Movable and Jumpable, each
having a method move() and jump() respectively. Implement both interfaces in a class
Robot and demonstrate how a class can inherit from multiple interfaces.
15. Implement a Java program that demonstrates multiple inheritance using interfaces by
creating three interfaces Runnable, Walkable, and Swimmable. Implement all three in a
class Triathlete. Write a program to call each of the methods from the Triathlete class.
Assignments
1. Develop a Java application with below given specifications using inheritance.
Class named Person with attributes name, age and weight
Class named Student extends Person with additional attributes of id, marks and course.
Class named Employee extends Person with additional attributes empid, designation and
salary.
Read two students and two employees data and display them.
2. Develop a Java application with below given specifications using inheritance.
Class named Student with attributes id, name and age
Class named StudentMarks extends Person with additional attributes of five subject marks
and cgpa.
Class named Grade extends StudentMarks with additional attribute grade.
Read all attributes of a student and calculate cgpa and grade.
3. Create a java program with a super class “Shape” with attributes length, breadth and a method area
(non-implemented method). Derive two subclasses Rectangle and Triangle from Shape class, and
implement area. Use Shape class reference variable to access subclass methods.
4. Develop a user defined package “Operations” that contains two classes namely “Arithmetic” and
“Relational” with different methods related to class operations. Arithmetic includes methods add(),
sub(), mul(). Relational includes methods greater(), lesser(), equals(). import these classes into
another Java program of different package and utilize their methods to perform operations.
5. Develop a java program to demonstrate Queue data structure using interface. Queue should
support the following operations:
insert() – inserts the specified element into queue.
delete()- removes and returns head of the queue.
display()- displays all elements in order.
peek() – only returns the head element.