Practical Oop

Download as pdf or txt
Download as pdf or txt
You are on page 1of 47

Practical-1

Install JDK and Setup a Java Programming development environment by using: 1) Command Prompt
(SET PATH command and using Environment Variable). 2) Any open source IDE (Eclipse, Jcreater etc)
Practical-2
Test the java development environment setup by implementing a simple java program (print: “OOP
with JAVA”).

Output:
Practical-3
Develop a basic java program that demonstrates data types of JAVA.

Output:
Practical-4
Develop a Java program to swap two numbers without using a temporary variable and with using a
temporary variable (use command line argument to accept value from user).

Output:
Practical-5
Develop programs to demonstrate use of - 1) if statement and its different form

2) switch case statement

Output:
2)for switch statement

Output:
Practical-6
Develop program to demonstrate use of1) for loop

2) ‘while’ and ‘do while’ loop

Output-
2)while-loop

Output:
Practical-7
Develop a Java program to find maximum and minimum numbers from array elements.

Output:
Practical-8
Develop a basic java program that demonstrates the use of Class & Object
Output:
Practical:9
Develop a java program to find the factorial of a given number using a recursive function.

Output:
Practical-10
Develop a java program that demonstrates method overloading.

Output:
Practical-11
Develop a program for implementation of different functions of String class.

Output:
Practical-12
Develop a program for implementation of Wrapper Class to convert primitive value into object
(Boxing) and object into primitive value (Un-boxing).

Output:
Practical-13
Develop a program with a static block and show that it will be executed before the main ( ) method in
a class.

Output:
Practical-14
Develop a program to demonstrate use of static functions.

Output:
Practical-15
Develop a program to demonstrate use of ‘this’ keyword. Check whether ‘this’ can access the private
members of the class or not.

Output:
Practical-16
Develop a program with an overloaded constructor. Also develop the copy constructor to create a
new object with the state of the existing object.

Output:
Practical-17
Develop a program to demonstrate the use of private constructor and also write a method which will
count the number of instances created using default constructor only.

Output:
Practical-18
Develop a program to demonstrate single inheritance, multilevel inheritance, and hierarchical
inheritance.
Output:
Practical-19
Develop a program with one class named shape which has two member functions named erase ()
and draw (). In the program we have three other subclasses: circle, triangle and square. override
methods of the superclass into subclasses.
Output:
Practical-20
Develop a program for implementation of Dynamic method dispatch.
Output:
Practical-21
Develop a java program that demonstrates the use of Abstract class.
Output:
Practical-22
Develop a java program that illustrates interface inheritance. Interface ‘A1’ and ‘A2’ are extended
from interface ‘A’. Interface ‘A12’ inherited from both ‘A1’ and ‘A2’. Each interface declares one
method and one constant. Class ‘Interface_Imple’ implements ‘A12’. Instantiate ‘Interface_Imple’ and
invoke each of its methods. Each method displays one of the constants.
Output:
Practical-23
Develop a program to create a Package and demonstrate how packages are used in java. And use java
access modifier to demonstrate the access rules in a package.

Step 1: Create a Package

1)classA.java
2).ClassB.java

Step 2: Create a Main Class to Use the Package


Output:
Practical-24
Develop a program to demonstrate the use of ‘super’ and ‘final’ keywords.

Output:
Practical-25
Develop programs to demonstrate the use of Exception Handling using predefined Exception Classes.

Output:
Practical-26
Develop a program to handle multiple exceptions using multiple try blocks and multiple catch blocks.

Output:
Practical-27
Develop a program to implement user defined exceptions.

Output:
Practical-28
Develop a program to demonstrate use of throw, throws, and finally keyword.
Output:
Practical-29
Develop a program that executes two threads. One thread displays “Java Programming” every 2
seconds, and the other displays “Semester - 4th” every 5 seconds.(Create the threads by extending
the Thread class)
Output:
Practical-30
Develop a program that executes two threads. One thread will print the even numbers and the
another thread will print odd numbers between 1 to 10.(Create the thread by implementing
runnable interface)
Output:
Practical-31
Develop a program to demonstrate use of synchronization of threads when multiple threads are
trying to update a common variable.

Output:
Practical-32
Develop programs to create, write, modify, read operations on Text files.
Output:sS

You might also like