0% found this document useful (0 votes)
12 views3 pages

Assignment 1

Network thoery assignment
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)
12 views3 pages

Assignment 1

Network thoery assignment
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/ 3

MADANAPALLE INSTITUTE OF TECHNOLOGY & SCIENCE

(UGC-AUTONOMOUS INSTITUTION)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
NAAC Accredited with A+ Grade, NIRF India Rankings 2021 - Band: 201-250 (Engg.)
NBA Accredited - B.Tech. (CIVIL, CSE, ECE, EEE, MECH), MBA & MCA

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


Course Name Code & Name: 20CSE301 – JAVA PROGRAMMING (OE II)

Academic Year : 2023 - 24 Class & Sem : III Year & II Sem
Date : 22.02.2024 Faculty Name : Ms. Thripthi P Balakrishnan

ASSIGNMENT I
Question
S.No Reg. No
Numbers
21691A04F5,21691A04F7, 21691A04G0, 21691A04G2, 21691A04G3,
1 21691A04G4,21691A04G5,21691A04G6,21691A04G9,21691A04H0, Set-1
21691A04H1
21691A04H3,21691A04H4,21691A04H5,21691A04H6,21691A04H7,
2 21691A04H8, 21691A04H9, 21691A04I0, 21691A04I3, 21691A04I4, Set-2
21691A04I5
21691A04I6, 21691A04I7, 21691A04I8, 21691A04J0, 21691A04J1,
3 21691A04J2, 21691A04J3, 21691A04J4, 21691A04J5, 22695A0413, Set-3
22695A0414
22695A0415, 22695A0416, 21691A04J7, 21691A04J8, 21691A04K2,
4 21691A04K6, 21691A04K7, 21691A04K9, 21691A04L1,21691A04L2, Set-4
21691A04L3
21691A04L5, 21691A04L6, 21691A04L8, 21691A04L9,21691A04M0,
5 21691A04M1,21691A04M2,21691A04M6,21691A04M7,21691A04M8 Set-5
21691A04N0
21691A04N1,21691A04N2,21691A04N3,21691A04N4,21691A04N5,
6 Set-6
21691A04N6,21691A04N7,21691A04N8,21691A04N9,21691A04O0

Q Bloom’s
ASSIGNMENT QUESTIONS CO
No. Level

SET-1

What is Object oriented programming? Illustrate various OOPs concepts with


1 suitable example. 1 3

Write a Java program that demonstrates the use of four string handling
functions: length(), concat() and substring(). Your program should create two
strings str1 and str2, and then perform the following operations:
2 a) Calculate and print the length of str1. 2 3
b) Concatenate str2 to the end of str1 and print the resulting string.
c) Extract a substring from str2 starting from index 0 to index 2 (inclusive)
and print the substring.
MADANAPALLE INSTITUTE OF TECHNOLOGY & SCIENCE
(UGC-AUTONOMOUS INSTITUTION)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
NAAC Accredited with A+ Grade, NIRF India Rankings 2021 - Band: 201-250 (Engg.)
NBA Accredited - B.Tech. (CIVIL, CSE, ECE, EEE, MECH), MBA & MCA

SET-2
Write a Java program that incorporates a class named
FibonacciAndDigitSum containing two methods:
a) printFibonacci(int n): This method prints the Fibonacci series up to
3 a given number n. It should utilize a loop to generate the series. 1 3
b) calculateDigitSum(int number): This method calculates the sum of
digits of a given number. It should use a loop to extract digits and
sum them.

Develop a Java program to model an employee hierarchy using different


types of inheritance.
a) Define a base class called Employee. Every employee will have
attributes such as name, age, and salary.
Implement three types of inheritance:
 Single Inheritance: Create a class Manager that inherits from
Employee. Managers will have an additional data field department.
 Multilevel Inheritance: Create a class TeamLead that inherits from
4 2 3
Manager. TeamLeads will have an additional attribute teamSize.
 Hierarchical Inheritance: Create a class Developer and another class
Designer, both inheriting from Employee.
In the main method:
 Create instances of Manager, TeamLead, Developer, and Designer.
 Set their attributes accordingly.
 Print out the details of each employee, including their name, age,
salary, and any additional attributes specific to their role.

SET-3

What is a Constructor? Explain types of Constructors in Java? Write a java


5 1 3
program to find the Perimeter of a rectangle using Constructor.

Write a Java program to calculate the area of different shapes. Define a base
class called Shape. This class should have an abstract method named
calculateArea().Create subclasses of Shape for different types of shapes,
such as Rectangle, Circle, and Triangle. Each subclass should override the
6 2 3
calculateArea() method to provide the specific formula for calculating the
area of that shape.In the main method: Create instances of Rectangle, Circle,
and Triangle, set appropriate dimensions for each shape, call the
calculateArea() method for each shape and print out the calculated area.

SET-4

Explain polymorphism in Java? Illustrate how polymorphism can be


7 1 3
implemented by using method overloading with proper example.
MADANAPALLE INSTITUTE OF TECHNOLOGY & SCIENCE
(UGC-AUTONOMOUS INSTITUTION)
Affiliated to JNTUA, Ananthapuramu & Approved by AICTE, New Delhi
NAAC Accredited with A+ Grade, NIRF India Rankings 2021 - Band: 201-250 (Engg.)
NBA Accredited - B.Tech. (CIVIL, CSE, ECE, EEE, MECH), MBA & MCA

Develop a basic shape application that calculates the area of different


geometric shapes. Define an interface named Shape with a method double
calculateArea().Implement the Shape interface with two classes: Circle and
Rectangle. Circle should have a constructor that takes the radius as a
8 2 3
parameter. Rectangle should have a constructor that takes the length and
width as parameters. Write a Java program that demonstrates the use of the
Shape interface and its implementations. Create objects of Circle and
Rectangle, calculate the area for each shape, and print the results.

SET-5

Define access modifiers in Java. Develop a java program to illustrate the usage
9 1 3
of various access modifiers.

Develop a Java application that performs basic mathematical operations.


Create a Java package named math that contains a class named Calculator.
This class should have methods to perform addition, subtraction,
10 multiplication, and division of two numbers. Outside the math package, write 2 3
a Java program that demonstrates the usage of the Calculator class. Import
the Calculator class from the math package and use its methods to perform
various mathematical operations on two numbers entered by the user.

SET-6

Write a Java program that initializes a square 2D array of integers and


11 calculates the sum of the diagonal elements (both main diagonal and anti- 1 3
diagonal). Display the sum as output.

Define an abstract class called Animal. This class should have attributes
such as name, age, and an abstract method named feed(). Create subclasses
of Animal for different types of animals, such as Cat, Dog, and Bird.
12 Implement the feed() method in each subclass to specify the type of food 2 3
each animal eats. In the main method: Create instances of Cat, Dog, and Bird,
Set appropriate details for each animal, such as name and age, Call the feed()
method for each animal and print out the type of food they eat..

You might also like