DEPARTMENTOFCOMPUTERSCIENCE&ENGINEERING
L T P C
II Year– II Semester 0 0 3 1.5
JAVAPROGRAMMINGLAB
Course Objectives:
The aim of this lab is to
Practice programming in the Java
Gainknowledgeofobject-orientedparadigmintheJavaprogramminglanguage
Learn use of Java in a variety of technologies and on different platforms
Course Outcomes:
By the end of the course student will be able to write java program for
Evaluate default value of all primitive data type, Operations, Expressions, Control-
flow, Strings
Determine Class, Objects, Methods, Inheritance, Exception, Runtime Polymorphism,
User defined Exception handling mechanism
Illustrating simple inheritance, multi-level inheritance, Exception handling mechanism
Construct Threads, Event Handling, implement packages, developing applets
Exercise - 1 (Basics)
a) Write a JAVA program to display default value of all primitive data type of JAVA
b) Write a java program that display the roots of a quadratic equation ax2+bx=0. Calculate the
discriminate D and basing on value of D, describe the nature of root.
c) Five Bikers Compete in a race such that they drive at a constant speed which may or may not
be the same as the other. To qualify the race, the speed of a racer must be more than the
average speed of all 5 racers. Take as input the speed of each racer and print back the speed of
qualifying racers.
Exercise - 2 (Operations, Expressions, Control-flow, Strings)
a) Write a JAVA program to search for an element in a given list of elements using binary search
mechanism.
b) Write a JAVA program to sort for an element in a given list of elements using bubble sort
c) Write a JAVA program to sort for an element in a given list of elements using merge sort.
d) Write a JAVA program using String Buffer to delete, remove character.
Exercise - 3 (Class, Objects)
a) Write a JAVA program to implement class mechanism. Create a class, methods and invoke
them inside main method.
b) Write a JAVA program to implement constructor.
Exercise - 4 (Methods)
a) Write a JAVA program to implement constructor overloading.
b) Write a JAVA program implement method overloading.
Exercise - 5 (Inheritance)
a) Write a JAVA program to implement Single Inheritance
b) Write a JAVA program to implement multi level Inheritance
c) Write a java program for abstract class to find areas of different shapes
Exercise - 6 (Inheritance - Continued)
a) Write a JAVA program give example for “super” keyword.
b) Write a JAVA program to implement Interface. What kind of Inheritance can be achieved?
Exercise - 7 (Exception)
a) Write a JAVA program that describes exception handling mechanism
b) Write a JAVA program Illustrating Multiple catch clauses
Exercise – 8 (Runtime Polymorphism)
a) Write a JAVA program that implements Runtime polymorphism
b) Write a Case study on run time polymorphism, inheritance that implements in above problem
Exercise – 9 (User defined Exception)
a) Write a JAVA program for creation of Illustrating throw
b) Write a JAVA program for creation of Illustrating finally
c) Write a JAVA program for creation of Java Built-in Exceptions
d)Write a JAVA program for creation of User Defined Exception
Exercise – 10 (Threads)
a) Write a JAVA program that creates threads by extending Thread class .First thread display
“Good Morning “every 1 sec, the second thread displays “Hello “every 2 seconds and the third
display “Welcome” every 3 seconds ,(Repeat the same by implementing Runnable)
b) Write a program illustrating isAlive and join ()
c) Write a Program illustrating Daemon Threads.
Exercise - 11 (Threads continuity)
a) Write a JAVA program Producer Consumer Problem
b) Write a case study on thread Synchronization after solving the above producer consumer
problem
Exercise – 12 (Packages)
a) Write a JAVA program illustrate class path
b) Write a case study on including in class path in your os environment of your package.
c) Write a JAVA program that import and use the defined your package in the previous Problem
Exercise - 13 (Applet)
a) Write a JAVA program to paint like paint brush in applet.
b) Write a JAVA program to display analog clock using Applet.
c) Write a JAVA program to create different shapes and fill colors using Applet.
Exercise - 14 (Event Handling)
a) Write a JAVA program that display the x and y position of the cursor movement using
Mouse. b) Write a JAVA program that identifies key-up key-down event user entering
text in a Applet