CJP Question Bank
CJP Question Bank
1 UNIT-1
2 Features of Java, Byte Code and Java Virtual Machine, JDK
5 (i) Java program is to be compiled first and then to be interpreted for execution. True or 3/4
false? Justify your answer. ()
6 Explain features of JAVA OR List various features of Java? Also explain any two feature 7
with example. (,)
7 Describe the following features of java: 1)Multithreaded 2)Architecture-neutral 7
3)Interpreted 4)High performance 5)Distributed 6)Portable 7) Dynamic ()
8 Compare Object oriented programming with sequential programming. () 7
9 List OOP characteristics and describe inheritance with examples. () 7
10 Data types, Operator Control Statements – If , else, nested if, if-else ladders, Switch, while,
do-while, for, for-each, break, continue.
Explain public static void main. In detail. 3/4
11 OR
(ii) Method main is a public static method. Justify. ()
12 (i) Explain short circuited operators. () 3/4
13 Explain short circuited operators and shift operators. 3/4/7
14 What is variable? How can we define variable in java? Also list rules for valid variable 7
names. ()
15 Single and Multidimensional Array
18 Write a program that creates and initializes a four integer element array. Calculate and 7
display the average of its values. ()
19 String class, StringBuffer class,Operations on string,, Command line argument, Use of
Wrapper Class.
20 Compare ii) String class and StringBuffer class. () 2/3
21 Differentiate String class and StringBuffer class with explanation of its methods. . ( June- 3/4/7
12,Jan-13, June-14,) OR Compare String with StringBuffer class. ()
22 Compare String with StringBuffer. Also write a program to count occurrence of character 3/4/7
in a string. ( Dec-13)
State whether any error exists in the following code. If so, correct the error and give 3/4
output. . (Nov-11)
class Test {
public static void main(String args[]) {
A a = new A();
a.print();
}
}
class A {
String s;
A(String s) {
this.s=s;
}
public void print() {
System.out.println(s);
23 }
}
24 Write a java program to do sum of command line argument passed two Double numbers. 7
()
25 What is Wrapper class in Java? Explain with examples.() 7
26 UNIT-1I
41 Discuss public, private, protected and default access modifier with example. () OR What 7
is visibility modifier? Explain all with example. ()
42 Explain constructor and finalizer with the help of example. 7
43 Explain this reference, key word static and garbage collection. (June-11, ) 7
44 Explain garbage collection and finalize method in JAVA. () 7
45 Nested class, Inner class, Anonymous inner class, Abstract class.
85
Write a program to demonstrate the multipath inheritance for the classes having relations 7
as shown in figure 2 A-> (B, C) ->D. (
86
88 Explain package in java. List out all packages with short description. (OR What is 3/4/7
package? List various built in package used in java. ()
89 What is package? Explain steps to create package with example. (,) 3/4/7
94 What is error? Explain various types of errors. How can we handle run time errors in java? 7
()
Explain the importance of Exception handling in java. Write a program to handle 7
95 NoSuchMethodException, ArrayIndexOutofBoundsException using try-catch-finally and
throw. (Dec-10)
96 Enlist and explain the difference between error and exception. Write a program to handle 7
InterruptedException, IllegalArgumentException using try-cat-finally and throw . ()
97 Explain the importance of exception handling in java. Which key words are used to handle 7
exceptions? Write a program to explain the use of these keywords. ()
98 Explain transient, finally, throw, throws. () 7
104 What is Exception? Explain various Built-in exceptions in java. Also give difference 7
between throw and throws keywords. ()
105 Explain Exception handling in JAVA. Write an application that generates custom 7
exception if any value from its command line arguments is negative. (
Write a method for computing xy by doing repetitive multiplication. x and y are of type 7
integer and are to be given as command line arguments. Raise and handle exception(s) for
106 invalid values of x and y. Also define method main. Use finally in above program and
explain its usage. ()
Write an application that searches through its command-line argument. If an argument is 7
107 found that does not begin with and upper case letter, display error message and terminate.
()
Write a method for computing xy doing repetitive multiplication. X and y are of type 7
108 integer and are to be given as command line arguments. Raise and handle exception(s) for
invalid values of x and y. ()
109
UNIT-1II
110 Use of Multithread programming, Thread class and Runnable interface
111 Draw and explain life cycle of thread. Also list and explain various methods of thread. (,) 7
112 Explain the life cycle of a thread. (,)
113 What is a thread? Describe the complete life cycle of with example. ()
What is multithreading? Why it is required? Write a program that creates three threads. 7
Make sure that the main thread executes last. ()
115 OR
Explain multi threading in java using example. ()
116 Explain Thread life cycle and describe creation of thread with suitable example. () 7
117 Thread priority, Thread synchronization, Thread communication, Deadlock
125 Explain interprocess communication mechanism (wait(), notify() and notifyall()) being 7
used by java to avoid polling . ()
126 Why synchronization is required in multithreaded programming. Write a program that uses 7
thread synchronization to guarantee data integrity in a multithreaded application.. (
127 Explain wait, notify, synchronized and native methods. () 7
128 Explain wait, notify, notifyall, synchronized methods in thread. () 7
Write a complete multi-threaded program to meet following requirements: 7
- Read matrix [A] m x n
- Create m number of threads
- Each thread computes summation of elements of one row, i.e. i th row of the
129 matrix is processed by i th thread. Where 0 <= i < m.
- Print the results. . ()
Write an application that creates and starts three threads. Each thread is instantiated from 7
the same class. It executes a loop with 10 iterations. Each iteration displays string
130 "HELLO", sleeps for 300 milliseconds. The application waits for all the threads to
complete & displays the message "Good Bye..." ()
Write an application that executes two threads. One thread displays "Good Morning" every 7
131 1000 milliseconds & another thread displays "Good Afternoon" every 3000 milliseconds.
Create the threads by implementing the Runnable interface. ()
Write a program to create two threads, one thread will print odd numbers and 7
Second thread will print even numbers between 1 to 20 numbers. ()
OR
132 Write a program to create two threads, one thread will print odd numbers and second
thread will print even numbers between 1 to 100 numbers. ()
Write a complete multi-threaded program to meet following requirements: 7
o Two threads of same type are to be instantiated in the method main.
o Each thread acts as a producer as well as a consumer.
o A shared buffer can store only one integer information along with the source &
destination of the information at a time.
o The information produced is to be consumed by appropriate consumer.
133 o Both producers produce information for both consumers.
o Each thread produces 5 information. ()
It is required to add two MxN sized matrices having integer elements to 7
produce a third resultant matrix of size MxN.
Write a complete multi-threaded program to meet following
requirements:
- Accept all required arguments from the command line.
- Instantiate M threads – with id 0 to M -1 respectively, each thread
134 performing addition of elements on the row specified by its id to
Produce corresponding row of the resultant matrix. ()
135 Write a program of writing binary file using multithreading. Demonstrate use of join() and 7
yield() interrupt(). ()
Write a multithreaded program to print all odd positive numbers in ascending order up to 7
n, where n is a positive integer number given as a command line argument. Instantiate
136 requited number of threads, where each thread except the last, examines next 50 numbers
and the last thread examines remaining numbers up to n. ()
Write a multi-threaded program to have two producer threads, each writes (push) total 7 7
integer items to the same (common) stack. The producers enter into sleep state for 500 ms
after writing every item. There is one consumer thread that reads (pop) from the same stack
and enters into sleep state then-after for 600 ms. Assume stack size as 10. Incorporate all
137 required conditions so that all valid items are popped only once and there is no stack
overflow & underflow. ()
138 Introduction to Stream, Byte Stream, Character stream, Readers and Writers
144 Write a program to display the bytes of a file in reverse sequence. Provide the name of the 7
file as a command line argument. (Use RandomAccessFile). (June-12)
Write a program that takes input for filename and search word from commandline 7
145 arguments and checks whether that file exists or not. If exists, the program will display
those lines from a file that contains given search word. ()
Write a program that counts the no. of words in a text file. The file name is passed as a 7
146 command line argument. The program should check whether the file exists or not. The
words in the file are separated by white space characters. . ()
147 Write a program to count the total no. of chars, words, lines, alphabets, digits, white spaces 7
in a given file. . ()
148 Write a program to replace all “word1” by “word2” from a file1, and output is written to 7
file2 file and display the no. of replacement. (,)
149 Write a program to replace all “word1” by “word2” to a file without using temporary file 7
and display the no. of replacement. ()
Write a program to check that whether the name given from command line is file or not? If 7
it is a file then print the size of file and if it is directory then it should display the name of
150 all files in it. () OR Write a program that counts number of characters, words, and lines
in a file. Use exceptions to check whether the file that is read exists or not. ()
Write a program that counts the no. of words in a text file. The file name is passed as a 7
151 command line argument. The program should check whether the file exists or not. The
words in the file are separated by white space characters. ()
152 Write an application that reads a file and counts the number of occurrences of digit 5. 7
Supply the file name as a command-line argument. ()
153 Write a Java program to copy content of file1.txt to file2.txt using Java file handling. () 7
158 i)What is collection in Java? Differentiate between Vector and ArrayList () 3/4/7
ii) Explain the unique features of Map interface.. (,)
159 Compare List, Set and Map interfaces. Also compare ArrayList, TreeSet and HashMap 7
classes in java. ()
160 Explain utility class Hashtable and instanceof operator by giving examples. () 7
161 Describe the Java Collections Framework. () List the interfaces, abstract classes and 7
concrete classes of collection hierarchy. ()
162 Write a complete program to implement a singly linked list with nodes storing 7
integer information using suitable utility class. ()
163 Explain use of Linked List collection class with example. () 7
164 UNIT-1V
InetAddress class,Socket class, DatagramSocket class, DatagramPacket class
165 InetAddress class
166 Explain basic terminology related to Network Programming: [1/2 Marks Each] 3/4
1) Socket 2) Port 3)Protocol 4)IPAddress 5)URL
167 Write the use of InetAddress class. List and explain the methods of it. 3/4/7
168 Write the program to print the IP address of the local machine. 3/4/7
169 Write a note on Network programming in Java. () 7
170 List and write the use of classes available in java.net Package. 7
171 Socket class