OOPS Lab File-2
OOPS Lab File-2
OOPS Lab File-2
LAB FILE
Ansh Tyagi
500105272
R2142220033
Batch-2(devops)
Lab 1.
TITLE: Introduction to Java Environment
1. Installation of JDK
2. Setting of path and classpath
3. Introduction to Eclipse
click on the x64 installer to install the jdk.
After the completion download of the .exe file. Click on
that file and run the file.
After that you have to click on next button to just setup
in your system.
Answers:
Lab 3.
TITLE: Basic Java Programming
1.Write a program to accept 10 student’s marks in an array, arrange it
into ascending order, convert into the following grades and print marks
and grades in the tabular form.
2.Write a program to accept three digits (i.e. 0 - 9) and print all its possible
combinations.
(For example, if the three digits are 1, 2, 3 than all possible combinations
are: 123, 132,
213, 231, 312, 321.)
5.Write a program to find the sum of all integers greater than 40 and less
than 250 that are divisible by 5.
Lab 4.
TITLE Inheritance
1.Write a Java program to show that private member of a super class cannot be
accessed from derived classes.
2.Write a program in Java to create a Player class. Inherit the classes Cricket
_Player, Football _Player and Hockey_ Player from Player class.
3.Write a class Worker and derive classes DailyWorker and SalariedWorker from it.
Every worker has a name and a salary rate. Write method ComPay (int hours) to
compute the week pay of every worker. A Daily Worker is paid on the basis of the
number of days he/she works. The Salaried Worker gets paid the wage for 40 hours
a week no matter what the actual hours are. Test this program to calculate the pay of
workers. You are expected to use the concept of polymorphism to write this program.
4.Consider the trunk calls of a telephone exchange. A trunk call can be ordinary,
urgent or lightning. The charges depend on the duration and the type of the call.
Write a program using the concept of polymorphism in Java to calculate the charges.
4.On a single track two vehicles are running. As vehicles are going in same direction
there is no problem. If the vehicles are running in different direction there is a chance
of collision. To avoid collisions write a Java program using exception handling. You
are free to make necessary assumptions.
2.Write a program that converts all characters of a string in capital letters. (Use
StringBuffer to store a string). Don’t use inbuilt function.
3.Write a program in Java to read a statement from console, convert it into upper
case and again print on console. (Don’t use inbuilt function)
4.Write a program in Java to create a String object. Initialize this object with your
name. Find the length of your name using the appropriate String method. Find
whether the character ‘a’ is in your name or not; if yes find the number of times ‘a’
appears in your name. Print locations of occurrences of ‘a’ .Try the same for different
String objects
Lab 9.
TITLE: Threads and Collections
1.Write a program to implement the concept of threading by extending
Thread Class and Runnable interface.
2.Write a program for generating 2 threads, one for printing even numbers
and the other for printing odd numbers.