Sie sind auf Seite 1von 2

Muhammad Ali Jinnah

University, Karachi

Department Of Computer Science

Fall 2019

Data Structures & Algorithms Lab

Instructors
Rida Ayesha
Aman Farooq
LAB # 1 - JAVA REFRESHER LAB

Note: Create separate class & method for each task.

Task # 1: Input 2 number from user & swap them. (Input numbers from user)
Task # 2: Using Constructor overloading, perform the addition of three integers.
(Input numbers from user)

Task # 3: Using two-dimensional Array, perform the addition of two matrices.


(Input matrix 1 & matrix 2 from user, also display the array index)

Task # 4: Create a private variable in a class. Read the value of a private variable
using the getter & setter methods.

Task # 5: Create a class. Create an object of ArrayList named CSClass in that


class. Now perform the following operations: (Create separate method for each)
● Add students using add method.
● Check if the class has any student or not.
● Show the number of students in class.
● Search for a student. For E.g: Ahmed
● Sort the student names in ascending order using Collections class.
● Sort the student names in descending order using Collections class.
● Remove a student from class.
● Remove all students from class.

Task # 6: Write to a text file & read its content.

Das könnte Ihnen auch gefallen