CE219.01 Practical List
CE219.01 Practical List
Practical List
PART-I
Data Types, Variables, Arrays, Operators, Control Statements, String
1. Introduction to Object Oriented Concepts, comparison of Java with other object oriented
programming languages. Introduction to JDK, JRE, JVM, javadoc, command line
argument
2. Write a program to calculate total surface area of the exterior of the house.
Ask user for
a) House length, width and height
b) Number of windows and size of window
c) Number of doors and size of door
Calculate total surface area to be painted.
3. Randomly generate two dice values 100 times and count how many times we roll in
doubles.
Ex. Two dice values roll into (1, 1), then increment counter by 1.
Hint: Import Random library.
3. Create an abstract class Robot that has the concretre subclasses , RobotA, RobotB,
RobotC. Class RobotA1 extends RobotA, RobotB1 extends RobotB and RobotC1 extends
RobotC. There is interface Motion that declares 3 methods forward(), reverse() and stop(),
implemented by RobotB and RobotC. Sound interface declare method beep() implemented
by RobotA1, RobotB1 and RobotC1. Create an instance method of each class and invoke
beep() and stop() method by all objects.
PART-IV
Exception Handling
1. WAP to show the try - catch block to catch the different types of exception.
2. WAP to generate user defined exception using “throw” and “throws” keyword.
Write a program that raises two exceptions. Specify two ‘catch’ clauses for the two
exceptions. Each ‘catch’ block handles a different type of exception. For example the
3.
exception could be ‘ArithmeticException’ and ‘ArrayIndexOutOfBoundsException’.
Display a message in the ‘finally’ block.
PART-V
File Handling & Streams
1. WAP to show how to create a file with different mode and methods of File class to find
path, directory etc.
2. Write a program to show a tree view of files and directories under a specified
drive/volume.
3. Write a program to transfer data from one file to another file so that if the destination
file does not exist, it is created.
4. WAP to show use of character and byte stream.
5. WAP to read console input and write them into a file.
(BufferedReader /BufferedWriter).
6. WAP to demonstrate methods of wrapper class.
PART-VI
Multithreading
1. Write a program to create thread which display “Hello World” message.
A. by extending Thread class
B. by using Runnable interface.
2. Write a program which takes N and number of threads as an argument. Program should
distribute the task of summation of N numbers amongst number of threads and final
result to be displayed on the console.
3. Write a program to increment the value of one variable by one and display it after one
second using thread using sleep() method.
4. Write a program to create three threads ‘FIRST’, ‘SECOND’, ‘THIRD’. Set the
priority of the ‘FIRST’ thread to 3, the ‘SECOND’ thread to 5(default) and the
‘THIRD’ thread to 7.
5. Write a program to solve producer-consumer problem using thread synchronization.
PART-VII
Collection Framework and Generic
1. Create a generic method for sorting an array of Comparable objects.
2. Write a program that counts the occurrences of words in a text and displays the words and
their occurrences in alphabetical order of the words. Using Map and Set Classes.
3. Write a code which counts the number of the keywords in a Java source file. Store all the
keywords in a HashSet and use the contains method to test if a word is in the keyword set.