Contains solutions for all OOP Lab Programs. This repository contains all you need for OOP Lab of KTU Semester 3. The program description are given below and you can open the corresponding program from the repository.
- 1.This is a simple Java program. Solution
- 2.Num Program. Solution
- 3.User input example. Solution
- 4.Find the sum of digits in an integer read from the keyboard. Solution
- 5.Find the largest of N numbers, without using array. Solution
- 6.Write a Java program that checks whether a given string is a palindrome or not. Solution
Input: String read from keyboard
Output: Message displayed. - 7.Write a Java program to find the frequency of given character in a string. Solution
Input: String read from keyboard Character read from keyboard.
Output: Number of occurrences of the character in the string - 8.Write a Java program to multiply two given matrices. Solution
Input: Dimensions of two matrices (MxN, PxQ) : If dimensions are suitable for multiplication, read two integer matrices, say A and B
Output: Matrices A, B and C = A*B displayed / Error message
- 9.Write a Java program to reverse a given string. Solution
- 10.Write a Java program to display the transpose of a given matrix. Solution
- 11.Write a Java program to find the second smallest element in an array. Solution
- 12.Write a Java program to check whether a given number is prime or not. Solution
- 13.Write two Java classes Employer 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.(ie. only one object creation allowed)
-> display() only prints the name of the class and doe snot return any value. Ex. "Name of class in Employee"
-> calcSalary() in Employee displays "salary of employee is 10000" and calcSalary() in Engineer displays "Salary of employee is 20000".
Solution - 14.Write a Java program to 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' 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. Solution
- 15.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. Solution
- 16.Write a Java program to calculate the area of different shapes namely circle, rectangle and triangle using the concept of method overloading. Solution
- 17.Write a Java program to demonstrate the use of garbage collector. Solution
- 18.Write a Java program for implementing a doubly linked list( elements of the list may be integers).
Make it a menu driven program with following options,
i) Insert (insertion may be at tail end)
ii) Delete (read the element to delete, search it and then delete, print error message if not found)
iii) Display list
iv) Exit.
Solution - 19.Write a Java program that implements Quick sort algorithm for sorting a list of numbers in ascending order. Solution
- 20.Write a Java program that implements Quick sort algorithm for sorting a list of names in ascending order. Solution
- 21.Write a Java program that implements the Binary Search algorithm. Solution
- 22.Extend the implementation of Singly linked list to Doubly Linked List. Solution
- 23.Extend the Quicksort program to sort a list of names. Use compareTo() method for comparing strings. Solution
- 24.Write a Java program to illustrate Interface Inheritance. Solution
- 25.Write a File Handling program in Java with Reader/Writer. Solution
- 26.Write a Java program that read from a file and write to file by handling all file related exceptions. Solution
- 27.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 that number. Solution
- 28.Write a Java program that shows Thread Synchronization. Solution
- 29.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). Solution
- 30.Write a Java program to display all records from a table using Java Database Connectivity (JDBC). Solution
- 31.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 exceptions like divide by zero. Use Java Swing. Solution
- 32.Write Java program that simulates a traffic light. The program lets the user select one of three lights.: Red, Green or Yellow. 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. Solution
- 33.Write a Java program that creates two textfields and a button named REVERSE.The first textfield inputs the string from the user and when the button is pressed the second textfield displays the each word reversed in a sentence. Solution
Made with ❤️ Jaison Dennis