Assignment 1
Assignment 1
(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
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
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.
SET-3
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
SET-5
Define access modifiers in Java. Develop a java program to illustrate the usage
9 1 3
of various access modifiers.
SET-6
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..