Skip to content

Latest commit

 

History

History
97 lines (84 loc) · 6.21 KB

File metadata and controls

97 lines (84 loc) · 6.21 KB

S3-OBJECT-ORIENTED-PROGRAMMING-LAB-IN-JAVA

KTU CSL 203


SYLLABUS


The syllabus contains six sessions (A, B, C, D, E, F). Each session consists of three concrete Java exercises, out of which at least two questions are mandatory.

(A) Basic programs using datatypes, operators, and control statements in Java.

  1. Write a Java program that checks whether a given string is a palindrome or not.
    Ex: MALAYALAM is palindrome.
  2. Write a Java Program to find the frequency of a given character in a string.**
  3. Write a Java program to multiply two given matrices.**

(B) Object Oriented Programming Concepts: Problem on the use of constructors, inheritance, method overloading & overriding, polymorphism and garbage collection:

  1. Write a Java program which creates a class named 'Employee' having the following members: Name, Age, Phone number, Address, Salary. It also has a method named 'printSalary( )' which prints the salary of the Employee. Two classes 'Officer' and 'Manager' inherits the 'Employee' class. The 'Officer' and 'Manager' classes have data members 'specialization' and 'department' respectively. Now, assign name, age, phone number, address and salary to an officer and a manager by making an object of both of these classes and print the same. (Exercise to understand inheritance). **
  2. Write a java program to create an abstract class named Shape that contains an empty method named numberOfSides( ). Provide three classes named Rectangle, Triangle and Hexagon such that each one of the classes extends the class Shape. Each one of the classes contains only the method numberOfSides( ) that shows the number of sides in the given geometrical structures. (Exercise to understand polymorphism). **
  3. Write a Java program to demonstrate the use of garbage collector.

(C) Handling different types of files as well as input and output management methods:

  1. Write a file handling program in Java with reader/writer.
  2. Write a Java program that read from a file and write to file by handling all file related exceptions. **
  3. Write a Java program that reads a line of integers, and then displays each integer, and the sum of all the integers (Use String Tokenizer class of java.util). **

(D) Exception handling and multi-threading applications:

  1. Write a Java program that shows the usage of try, catch, throws and finally. **
  2. Write a Java program that implements a multi-threaded program which has three threads.
    First thread generates a random integer every 1 second. If the value is even, second thread computes the square of the number and prints. If the value is odd the third thread will print the value of cube of the number.
  3. Write a Java program that shows thread synchronization. **

    (E) Graphics Programming:

  4. Write a Java program that works as a simple calculator. Arrange Buttons for digits and the + - * % operations properly. Add a text field to display the result. Handle any possible exceptions like divide by zero. Use Java Swing. **
  5. Write a Java program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green. When a radio button is selected, the light is turned on, and only one light can be on at a time. No light is on when the program starts. **
  6. Write a Java program to display all records from a table using Java Database Connectivity (JDBC).

    (F) Standard Searching and Sorting Algorithms using data structures and algorithms learned from course Data Structures (CST 201):

  7. Write a Java program for the following: **

  8. Create a doubly linked list of elements.
  9. Delete a given element from the above list.
  10. Display the contents of the list after deletion.
  11. Write a Java program that implements Quick sort algorithm for sorting a list of names in ascending order. **
  12. Write a Java program that implements the binary search algorithm.


    ** Mandatory


PRACTICE QUESTIONS



1) Write a Java program to reverse an given string.
2) Write a Java program to display the transpose of a given matrix.
3) Write a Java program to find the second smallest element in an array.
4) Write a Java program to check whether a given number is prime or not.
5) Write a Java program to calculate the area of different shapes namely circle, rectangle, and triangle using the concept of method overloading.
6) Write two Java classes Employee and Engineer. Engineer should inherit from Employee class. Employee class to have two methods display() and calcSalary(). Write a program to display the engineer salary and to display from Employee class using a single object instantiation (i.e., only one object creation is allowed).
● display() only prints the name of the class and does not return any value. Ex. “ Name of class is Employee.”
● calcSalary() in Employee displays “Salary of employee is 10000” and calcSalary() in Engineer displays “Salary of employee is 20000.”
7) Write a Java program to illustrate Interface inheritance.
8) Write a Java program that shows how to create a user-defined exception.
9) Write a Java program to create two threads: One for displaying all odd number between 1 and 100 and second thread for displaying all even numbers between 1 and 100.
10) Write a Java program that shows thread priorities.
11) Write a Java program that reads a file and displays the file on the screen, with a line number before each line.
12) Write a Java program that displays the number of characters, lines and words in a text file.
13) Write a Java program for handling mouse events.
14) Write a Java program for handling key events using Adapter classes (general).
15) Write a Java program that allows the user to draw lines, rectangles and ovals.
16) Write a Java Swing program to print a wave form on the output screen.
17) Write a program to accept rollno, name, CGPA of “n” students and store the data to a database using JDBC connectivity. Display the list of students having CGPA greater than 7. (Use MySQL /PostgreSQL).
18) Write a Java program to implement Heap sort algorithm using array.