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

java index

The document outlines a series of programming assignments for a B.Sc Honours course in Computer Science at the University of Calcutta for the academic session 2022-2023. It includes tasks related to Java programming, such as creating classes, implementing methods, and handling data structures, with specific requirements and expected outputs for each assignment. The assignments cover various topics including object-oriented programming, data manipulation, and exception handling.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
3 views5 pages

java index

The document outlines a series of programming assignments for a B.Sc Honours course in Computer Science at the University of Calcutta for the academic session 2022-2023. It includes tasks related to Java programming, such as creating classes, implementing methods, and handling data structures, with specific requirements and expected outputs for each assignment. The assignments cover various topics including object-oriented programming, data manipulation, and exception handling.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

University Of Calcutta

Department Of Computer Science

B.Sc Honours (CMSA)


(Under C.B.C.S)

Semester – V
Session 2022-2023

CMSA – CC - 12 - P

CU Roll Number: 223142 - 21 - 0049


CU Registration Number: 142 - 1111- 0501- 22
INDEX
SL. Problem Statement Date Signature
No.

1. A class called Mypoint, which models a 2D point with x 17/09/2024


and y co-ordinates. It contains:

(a) Two instance variables x(int) and y(int).

(b) A default constructor that constructs a point at the


default location of (0, 0).

(c) An overloaded constructor that construct a point


with the given x and y co-ordinates.

(d) A method getData( ) to take values of x and y from


user.

(e) A method called linesegment (MyPoint m, MyPoint


n) that find out the gradient of theline segment and
returns it from the function.

Write the MyPoint class in Java and also write a class


Gradient-check to test all the public methods defined in
the class MyPoint.

2. Write a program in Java to create a base class 'Square' 17/09/2024


having instance variable ‘side : double'. Initiate variable
using constructor, a method 'get Volume( ) : double'
that calculates volume and print it. Create a derived
class ‘Cylinder' having instance variable ‘height :
double'. Initiate variables of both classes through
constructor, override method 'get Volume(0: double' to
calculate volume of cylinder taking 'side' variable of
base class as 'radius' and print it.

3. Write a program in Java with class Employee and do the 20/09/2024


following operations on it

(a) Create two constructor default and with object as


parameter to initialize class variable.

(b) Create a employee function and return Calculate' all


values which as calculates the HRA, DA andgross on the
basic pay of an object.HRA = 12% of basic pay, gross =
basic pay + HRA + DA DA = 3% of basic pay.
(c) Display the details of the employees whose gross is
more than Rs 50,000

4. Create a class Box' having parameterized constructor 20/09/2024


with an object argument to initialize ‘breadth' , ‘length'
and 'height' and also create a method Volume( ) which
returns the volume of the box. Write a Java program to
create the class and a test driver main class to test all
functions mentioned above

5. Create a Java program to create and display a singly 25/09/2024


linked list. Also write a list. function to reverse the list.

6. Using methods charAt( ) and lengths( ) of string class, 25/09/2024


write a Java program to print the frequency of each
character in a String.

7. Write a Java program to print all permutations of a 01/10/2024


given string of length 3 (repetition not allowed). Eg. If
the given string is ABC then the permutated strings are
CAB, BCA. ABC, ACB, BAC, CBA.

8. Write a Java program to replace a specified character 01/10/2024


with another character.

Example:

Input : The quick brown fox jumps over the lazy dog.
Replace 'd' with f

Output : The quick brown fox jumps over the lazy fog.

9. A class DeciOct has been defined to convert a decimal 18/11/2024


number into its equivalent octal number. Some of the
members of the class are given below :

Class name : DeciOct

Data members/instance variables :

n: stores the decimal number

oct: stores the octal equivalent number

Member functions :

DeciOct(): constructor to initialize the data members

n = 0. oct = 0.

void getnum(int nn) : assign nn to n

void deci_oct(): calculates the octal equivalent of 'n' and


stores it in oct using the recursive technique

void show() : Displays the decimal number n, calls the


function deci_oct and displays its octal equivalent

Also define a main() function to create an object and call


the functions accordingly to enable the task.

10. Write a program in Java that accepts a 2D matrix and 21/11/2024


prints the matrix with row minimum and column
minimum values. Also find the maximum and minimum
value in the 2D array

Input :

435

107

846

Output :

Row minimum = 3 0 4

Column minimum = 1 0 5

Maximum value = 8 Minimum value =0.

11. Take an input string that will consist of a number of 25/11/2024


lines of English text consisting of the letters of the
English alphabet, the punctuation marks () apostrophe,
(.) full stop (,) comma, (;) semicolon, (:) colon and white
space characters (blank, new line). Print the words of
the text in reverse order without any punctuation marks
other than blanks.

Eg :

This is a sample piece of text to illustrate this question.

If you are smart you will solve this right

Output:

right this solve will you smart are you If question this
illustrate to text of piece sample a is This.

12. Write a Java program to get a substring of a given string 05/12/2024


between two specified positions. Example:

Input : The quick brown fox jumps over the lazy dog.
Specified Positions : 10, 25

Output: brown fox jumps


13. Write a program to create two threads, one prints 09/12/2024
‘Hello' and other prints ‘Hi’.

14. Write a program to create your own exception as 13/12/2024


NegativeSizeException whenever negative values are
put in an array.

You might also like