0% found this document useful (0 votes)
390 views17 pages

OOP-I Question - Bank

The document contains a question bank for an Object Oriented Programming course. It includes questions about Java fundamentals like data types, operators, control structures, classes and objects. The questions cover topics from introductory Java concepts to more advanced OOP principles and there are over 30 multiple choice and code writing questions included.

Uploaded by

xitekol233
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
390 views17 pages

OOP-I Question - Bank

The document contains a question bank for an Object Oriented Programming course. It includes questions about Java fundamentals like data types, operators, control structures, classes and objects. The questions cover topics from introductory Java concepts to more advanced OOP principles and there are over 30 multiple choice and code writing questions included.

Uploaded by

xitekol233
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Ahmedabad Institute of Technology

CE & IT Department (Sem IV)

Object Oriented Programming-I (3140705)

Question Bank

CE Department Vision:
Year: 2020-2021
To produce technically sound and ethically responsible Computer Engineers to the society by providing
Quality Education.
Prepared By: Prof. Shital V. Patel
CE Department Mission:
1)To provide healthy Learning Environment based on current and future Industrial demands.
2)To promote curricular, co-curricular and extra-curricular activities for overall personality
development of the students.
3)To groom technically powerful and ethically dominant engineers having real life problem solving
capabilities.
4)To provide platform for Effective Teaching Learning.

IT Department Vision:
To provide quality education and assistance to the students through innovative teaching learning
methodology for shaping young mind technically sound and ethically strong.

IT Department Mission:
1)To serve society by producing technically and ethically sound engineers.
2)To generate groomed and efficient problem solvers as per Industrial needs by adopting innovative
teaching learning methods.
3)To emphasis on overall development of the students through various curricular, co-curricular and
extra-curricular activities.
Question Bank

Text Book: Y.Daniel Liang 10E Marks

UNIT- 1 (Chapter 1,2) Introduction to java and elementary Programming:

1 JVM is platform dependent. Justify. (May-13,Dec-15,Nov-16) 1


2 There is no destructor in Java. (May-13,Dec-15) 1
3 List out different types of operators in JAVA. Explain Logical and BitwiseOperators in detail. (Dec-19) 4
4 Explain short circuited operators and shift operators. (June-11, May-13, June-14) 4
5 Explain features of Java briefly.(Nov-17 )(May-16)(Dec-19) 7
6 Java program is to be compiled first and then to be interpreted for execution. True or false? Justify your 4
answer. (Dec-15)
7 Discuss JVM, JRE, Javadoc. Why java is platform independent language? Mention advantages of Java 4
Programming Language (Dec-18)
8 Draw and explain the process of building and running JAVA Program.(Dec-19) 7
9 What are the four integer types supported in Java?(Apr-17) 4
10 What will be the result of the following java expression: 4*2-5>4&&3<5-2 (Apr-17) 4
11 List out different types of operators in JAVA. Explain Logical and Bitwise Operators in detail. (Dec-19) 4
12 Write a program to take three numbers as command line argument. Display the maximum among them? (June 4
19)
13 Define following. (Nov-18) 3
1) Byte code
2) Java Virtual Machine
14 Give the differences between JAVA and C++ (Dec-19) 4
15 Draw and explain the process of building and running JAVA Program (Dec-19) 7
16 What is command line argument? Explain it with program. (Dec-19) 7
17 Why java is preferred as a programing language for Internet? (Dec-20) 3
18 List out and explain three main principles of object-oriented programming? (Dec-20) 4
19 What is API, JDK and IDE? 3
20 What is a keyword? List some Javatroduction keywords. 3
21 What is a comment? Is the comment ignored by the compiler? How do you denote a comment line and 3
a comment paragraph?
22 Show the output of the following code: 3
public class Test {
public static void main(String[] args) {
System.out.println("3.5 * 4 / 2 – 2.5 is ");
System.out.println(3.5 * 4 / 2 – 2.5);
}
}
23 What are syntax errors (compile errors), runtime errors, and logic errors? 7
Give examples of syntax errors, runtime errors, and logic errors.

OOP-I (3140705) Page 2


Prof. Shital Patel
24 Are there any performance differences between the following two import statements? 3
import java.util.Scanner;
import java.util.*;
25 What are the benefits of using constants? Declare an int constant SIZE with value 20 . 3
26 What are the naming conventions for class names, method names, constants, and variables? 3
Which of the following items can be a constant, a method, a variable, or a class according to
the Java naming conventions?
MAX_VALUE , Test , read , readDouble
27 Translate the following algorithm into Java code: 4
Step 1: Declare a double variable named miles with initial value 100 .
Step 2: Declare a double constant named KILOMETERS_PER_MILE with value
1.609 .
Step 3: Declare a double variable named kilometers , multiply miles and
KILOMETERS_PER_MILE , and assign the result to kilometers .
Step 4: Display kilometers to the console.
What is kilometers after Step 4?
28 Show the output of the following code: 4
int a = 6;
int b = a++;
System.out.println(a);
System.out.println(b);
a = 6;
b = ++a;
System.out.println(a);
System.out.println(b);
29 What does an explicit casting from a double to an int do with the fractional part of the double value? 3
Does casting change the variable being cast?
30 Show the result of the following code: 4
System.out.println(2 * (5 / 2 + 5 / 2));
System.out.println(2 * 5 / 2 + 2 * 5 / 2);
System.out.println(2 * (5 / 2));
System.out.println(2 * 5 / 2);
31 Write a program that displays the area and perimeter of a circle that has a radius of 5.5 using the following 7
formula: perimeter = 2 * radius * p area = radius * radius * p
32 Assume a runner runs 14 kilometers in 45 minutes and 30 seconds. Write a program that displays the average 7
speed in miles per hour. (Note that 1 mile is 1.6 kilometers.)
33 Write a program that reads an integer between 0 and 1000 and adds all the digits in the integer. For example, if an 7
integer is 932, the sum of all its digits is 14.
UNIT- 2 (Chapter 3,4,5 ) Selections , Mathematical functions and loops
1 Write a java program to print prime number upto 100. (Apr-17) 3
2 Write a JAVA program to implement the Fibonacci series using for loop control structure. (Nov-19) 7

OOP-I (3140705) Page 3


Prof. Shital Patel
3 Analyze the following code. Is count < 100 always true , always false , or some- 3
times true or sometimes false at Point A, Point B, and Point C?
int count = 0;
while (count < 100) {
// Point A
System.out.println("Welcome to Java!");
count++;
// Point B
}
// Point C

4 What is the output of the following code? Explain the reason. 3


int x = 80000000;
while (x > 0)
x++;
System.out.println("x is " + x);
5 Write an if statement .(i)that increases pay by 3% if score is greater than 90.(ii)that assigns 1 to x if y is greater 3
than 0.
6 What is y after the following switch statement is executed? Rewrite the code using an if-else statement. 3
x = 3; y = 3;
switch (x + 3) {
case 6: y = 1;
default: y += 1; }
7 List and explain the various control statements in Java. Explain each control statement with examples 7
8 What are the differences between a while loop and a do-while loop? Convert the 7
following while loop into a do-while loop.
Scanner input = new Scanner(System.in);
int sum = 0;
System.out.println("Enter an integer " +
"(the input ends if it is 0)");
int number = input.nextInt();
while (number != 0) {
sum += number;
System.out.println("Enter an integer " +
"(the input ends if it is 0)");
number = input.nextInt();
}
9 What are the three parts of a for loop control? Write a for loop that prints the numbers from 1 to 100 . 7
10 Convert the following for loop statement to a while loop and to a do-while loop: 7
long sum = 0;
for (int i = 0; i <= 1000; i++)
sum = sum + i;
11 Write a program to print multiplication table in java 7
12 Write a program that prompts the user to enter two positive integers and finds their greatest common divisor. 7
13 Write a program that prompts the user to enter a three-digit integer and determines whether it is a palindrome 7
number. A number is palindrome if it reads the same from right to left and from left to right

UNIT- 3 (Chapter 6,7,8) Methods and Arrays

1 Create two dimensional array named marks‘ and initialize it(Apr-17) 3


2 Explain array implementation in Java. (Dec-15) 3
3 Explain Ragged Array With example (Nov-11) 3

OOP-I (3140705) Page 4


Prof. Shital Patel
4 Write a problem is to read 100 numbers, get the average of these numbers, and find the number of the items 7
greater than the average. (Dec_15)
5 Write a JAVA program to display the following output using 2-D array.(Dec-19) 7
0
12
345
6789
6 Write a program that creates and initializes a four integer element array. Calculate and display the average of its 7
values (Dec_15)
7 Write a java program to do sum of command line argument passed two Double numbers. (Dec_15) 7
8 Explain method overriding with example.(Dec-15) 7
9 Differentiate between Method overloading and Method overriding. Or 7
Explain Method overloading and Method overriding.(May-16) (Dec-19)
10 Define a recursive method for computing x raised to power y by doing repetitive multiplication where x 4
and y are positive integer numbers. Define main to use above method (Nov-16)
11 Write a method for computing first n terms of Fibonacci sequence. Define method main taking value of 4
n as command line argument and calling the method.(Nov-16)
12 Write a program which takes five numbers as command line argument from user, store them in one 4
dimensional array and display count of negative numbers. (Nov-18)
13 When will you declare a method as a static? Explain static method with suitable example (Nov-18) 3
14 Write a JAVA program to create a super class called figure that stores the dimensions of a two- 7
dimensional object. It also defines a method called area () that computes the area of an object. The
program derives two sub classes from figure. The first is rectangle and the second is Triangle. Each of
these subclasses overrides area (), so that it returns the area of a rectangle and a triangle respectively.
(Nov-19)
15 Describe the following methods related to String i) replace() ii) compareTo() (Nov-19) 3
Define a recursive method for computing x raised to power y by doing repetitive multiplication 7
where x and y are positive integer numbers. Define main to use above method.(Nov-16)
16 What are the benefits of using a method? 4
17 How do you define a method? How do you invoke a method? 3
18 Define the terms parameter, argument, and method signature. 3
19 How is an argument passed to a method? Can the argument have the same name as its parameter? 3
20 Write a program that overloads max method to find maximum of 2 integer and 3 double numbers 5
21 Write method headers (not the bodies) for the following methods: 5
a. Return a sales commission, given the sales amount and the commission rate.
b. Display the calendar for a month, given the month and year.
c. Return a square root of a number.
d. Test whether a number is even, and returning true if it is.
e. Display a message a specified number of times.
f. Return the monthly payment, given the loan amount, number of years, and annual
interest rate.
g. Return the corresponding uppercase letter, given a lowercase letter.
22 What is a local variable and scope of a variable? Explain in detail. 5
23 Write a program to convert a hexadecimal number AB8C to decimal number 7
24 Write a class that contains the following two methods: to Convert from celsius to fahrenheit and to convert from 7
fahrenheit to celsius
public static double celsiusToFahrenheit(double celsius)
public static double fahrenheitToCelsius(double fahrenheit)
25 When is the memory allocated for an array? 3

OOP-I (3140705) Page 5


Prof. Shital Patel
26 Indicate true or false for the following statements: 4
■ Every element in an array has the same type.
■ The array size is fixed after an array reference variable is declared.
■ The array size is fixed after it is created.
■ The elements in an array must be a primitive data type.
27 Which of the following statements are valid? 3
int i = new int(30);
double d[] = new double[30];
char[] r = new char(1..30);
int i[] = (3, 4, 3, 2);
float f[] = {2.3, 4.5, 6.6};
char[] c = new char();
28 Use the arraycopy method to copy the following array to a target array t: int[] source = {3, 4, 5}; 3
29 Write a program that returns reversed array ‘result’ from method ‘reverse’ using method header: public static 7
int[] reverse(int[] list) where list is input array.
30 Write a method that prints the maximum value in a list of an unspecified number of values by passing the list to 7
variable-length argument.
31 Write a program to use binary search on key=11 on following list 7
int[] list = {2, 4, 7, 10, 11, 45, 50, 59, 60, 66, 69, 70, 79};
32 Declare an array variable for a three-dimensional array, create a 4 * 6 * 5 int array, and assign its reference to 3
the variable.
33 Assume int[][][] x = new char[12][5][2], how many elements are in the array? What are x.length, x[2].length, 3
and x[0][0].length?
34 Declare an array reference variable for a two-dimensional array of int values, create a 4-by-5 int matrix, and 3
assign it to the variable.
35 Initialize 2-d arrays with random values between 0 and 99 3
36 Show the output of the following code: 3
public class Test {
public static void main(String[] args) {
int[][] array = {{1, 2, 3, 4}, {5, 6, 7, 8}};
System.out.println(m1(array)[0]);
System.out.println(m1(array)[1]);
}
public static int[] m1(int[][] m) {
int[] result = new int[2];
result[0] = m.length;
result[1] = m[0].length;
return result;
}
}
UNIT- 4 (Chapter 9) Objects and Classes

1 Define time class with hour and minute. Also define addition method to add two time objects.(Dec-15) 7

2 Differentiate the followings: (i) Constructor and method (Nov-11, May 18, Jan 13) 3
3 Explain both the types of constructors in detail(Dec 19) 4
4 It is required to compute SPI (semester performance index) of n students of a class for their registered subjects 7
in a semester. Assume that all students register for 6 subjects and each subject carry 5 credits. Also, follow GTU
convention and method for computation of SPI. Declare a class called student having following data members:
id_no, grades_obtained and spi.
Define constructor, display and calculate_spi methods. Define main to process data of n students(Nov-16)

OOP-I (3140705) Page 6


Prof. Shital Patel
5 Write a class named Rectangle to represent a rectangle. It contains following members: 7
DATA: width(double) and height (Double) that specify the width and height of the rectangle. Methods:(June-
19 )
1. A no-arg constructor that creates a default rectangle.
2. A constructor that creates a rectangle with the specified width and height.
3. A method named getArea() that returns the area of this rectangle.
4. A method named getPerimeter() that returns the perimeter.
6 Declare a class called employee having employee_id and employee_name as members. Extend class employee 7
to have a subclass called salary having designation and monthly_salary as members. Define following: -
Required constructors - A method to find and display all details of employees drawing salary more than Rs.
20000/-. - Method main for creating an array for storing these details given as command line arguments and
showing usage of above methods.(May-18)
7 When will you declare a method as a static? Explain static method with suitable example.(Dec-18) 7
8 Explain Java garbage collection mechanism. What is the purpose of the finalize()method.(Apr-17, Nov- 4
11,June-14)
9 Explain constructor and finalizer with the help of example. (Dec-13, June-14) 7
10 Explain keywords private and protected.(May-18)(Nov-16) 7
11 With the help of program show how to pass object as an argument of method(Nov-17) 7
12 Explain constructor overloading using example.(Dec-15)
13 Write a program to create circle class with area function to find area of circle.(Dec-15) 7
14 Differentiate between constructor and method of a class.(May-18) 4
15 Differentiate between protected and default access specifiers (May-19) 3
16 Distinguish between method overloading and overriding with suitable example. (May-19) (Nov-19) 4
(June 19)
17 What is constructor? Explain constructor overloading with example. (Nov-17) 4
18 What do you mean by Overloading? Explain constructor overloading with suitable example. (Nov-18) 4

19 What is a constructor in JAVA? How many types of constructors are there in JAVA? Explain with 4
examples. (Nov-19)
20 Discuss various access modifiers available in JAVA? How access modifier affects the visibility of a 7
member in different access locations? (Nov-19)
21 Justify: 7
1. Why we declare main() method as public and static member.
2. Why we generally declare constructor as public member.
3. Why there is no destructor in java. (June 19)
22 Explain static keyword in detail using a sample program (Dec-19) 7
What is the purpose of ‘this’ and ‘static’ keyword? Write a java program to explain this.(Dec-20) 4
23 Discuss public, private and protected access modifiers. 3
24 What do you mean by Object? Define class. 2/3
25 Differences between Variables of Primitive Types and Reference Types. 3
26 Explain following classes Date, Random, Point2D, System, and Math class with example. 7
27 Write a java program to calculate total and average to five values. Pass input values as constructor parameter. 7

28 Explain how you can pass and return objects using methods. 7
29 Explain immutable class and object with example. 7

OOP-I (3140705) Page 7


Prof. Shital Patel
UNIT- 5 (Chapter 10,11) Object oriented thinking:

1 Explain method parseInt.(Nov-16) 1


2 What is wrapper class? What is Autoboxing? OR What is Wrapper class in Java? Explain with examples. 3/7
(May-16)
3 Describe the following methods related to String i) replace() ii) compareTo() (Dec-19) 7
4 State whether any error exists in the following code. If so, correct the error and give output. (Nov-11) 7
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);}}
5 What are command line arguments? Write a java program which reads a line 03 from –command line and prints 3
that line in reverse.(Apr-17)
6 Write a method for computing first n terms of Fibonacci sequence. Define method main taking value of n as 7
command line argument and calling the method.(Nov-16)
7 Write a program to find whether the given string is palindrome or not. (Nov-17) 7
8 Describe Inheritance and its type with suitable example. (May-18 ,May-16) 3
9 What is compile time polymorphism? Use the compile time polymorphism in a java program to create objects. 4
(Apr-17)
10 What is inheritance in java? Explain different types of inheritance with proper example partial code. (May- 7
15,16, Apr-17,May-18)
11 Define polymorphism with its need. Define and explain static and dynamic binding (dynamic method dispatch) 7
to implement runtime polymorphism using program. (Dec-10,Jan-13, Apr-17,Nov-16)
12 Explain following with example: 7
i) Finalize() ii) static iii) super iv) final(May-16)
13 Explain following key words: this, super, instance of, static. .(Apr-17) 7
14 Declare a class called book having author_name as private data member. Extend book class to have two sub 7
classes called book_publication&paper_publication. Each of these classes have private member called title.
Write a complete program to show usage of dynamic method dispatch (dynamic polymorphism) to display book
or paper publications of given author. Use command line arguments for inputting data. . (May-13)
15 Write a JAVA program to create a super class called figure that storesthe dimensions of a two- dimensional 7
object. It also defines a method called area () that computes the area of an object. The program derives two sub
classes from figure. The first is rectangle and the second is Triangle. Each of these subclasses overrides area (),
so that it returns the area of a rectangle and a triangle respectively.(Dec-19)
16 The abstract vegetable class has three subclasses named Potato, Brinjal and Tomato. Write a java prog. That 7
demonstrates how to establish this class hierarchy. Declare one instance variable of type String that indicates the
color of a vegetable. Crete and display instances of these objects. Override the toString() method of object to
return a string with the name of vegetable and its color.(May-16)
17 Explain different Visibility modifiers. (May-18) 3
18 Explain keywords private and protected.(May-18) 4
19 Write a program which shows an example of function overriding. .(May-18) 7
20 What do you understand by super keyword? Write use of super keyword(May-19)(June 19) 3

OOP-I (3140705) Page 8


Prof. Shital Patel
21 Write an abstract class named Person and its two subclasses named Student and Employee.A person has 7
a name, address, phone number, and email address. A student has enrollment, course. An employee has
an office, salary, and designation. Define constructors and methods for input and display for both
classes. Write a main program to give demonstration of all.(May-19)
22 Explain Dynamic method dispatch with proper example. (Nov-17) (June 19) 7
23 Explain inner class with example.(Nov-18) 4
24 Discuss Following with example: (Nov-17) 7
(i) Super Keyword
(ii) Final Keyword
25 Explain following keywords of java with example.(Nov-18) 7
1) super
2) this
26 Explain the use of final keyword in JAVA. (Nov-19) 3
27 What is wrapper class? What is the use of wrapper class in Java? (Nov-18) 3
28 Explain Super keyword with the help of example. (Nov-19)(Dec-20) 4/7
29 How package can be created in JAVA? Explain with suitable example. (Nov-19) 4
30 Differentiate between final, finally and finalize. What will happen if we make class and method as final? 7
(June 19)
31 Explain Runtime Polymorphism with example (Dec-19) 7
32 State difference between String Class and StringBuffer Class. (May-18) 3
33 Explain the keywords: 1. Wrapper class 2. finalize () method 3. Recursion 4. Static. (May-18) 7
34 Explain the following terms: Abstraction, Encapsulation, Polymorphism and Inheritance. 4
35 What is package? How are they created and used? 3
36 What is the basic difference between string and stringbuffer object? 3
37 Write a program to count occurrence of character in a string. 7
38 Explain the various String functions with their syntax. 7
39 Which are the operations done on the string. Explain with examples. 7
40 Explain BigInteger and BigDecimal Classes with example. 7
41 Write a java program to do sum of command line argument passed two Float numbers. 7
42 Show a demonstration of how inheritance takes place through constructors. 4
43 Explain ArrayList class with its method in detail. 7
44 Declare a class called employee having employee_id and employee_name as members. Extend class employee 7
to have a subclass called salary having designation and monthly_salary
UNIT- 6 (Chapter 12,13) Exception Handling, I/O, abstract classes and interfaces

1 Differentiate the following:Checked and Unchecked exceptions (May-18) 2


2 Discuss exception and error(Nov-17) 2
3 What is Exception? Demonstrate how you can handle different types of exception separately.(Dec-18) 4
4 Explain garbage collection and finalization. (Dec-19)(May-17)(Nov-19) 3
5 Explain Exception handling in JAVA. Write an application that generates custom exception if any 7
value from its command line arguments is negative. (June-12, June-14 , Dec-13)
6 Define exception. List java‘s common exceptions. Write a JAVA program to generate and handle 7
division by zero arithmetic exception. (Dec-19)
7 Explain transient, finally, throw, throws. (Jan-13) 7
8 Explain & illustrate by examples use of final, finally and method finalize. (May-13)(May-19) 7

OOP-I (3140705) Page 9


Prof. Shital Patel
9 Write a method for computing �� by doing repetitive multiplication. x and y are of type integer and 7
are to be given as command line arguments. Raise and handle exception(s) for invalid values of x and
y. Also define method main. Use finally in above program and explain its usage. (June-11)
10 Write an application that searches through its command-line argument. If an argument is found that 7
does not begin with and upper case letter, display error message and terminate. (Dec-15)
11 Write a program to create user define exception MyException. Define a class ExceptionDemo that has 7
a method named compute( ) which throws a MyException object, when compute( )‘s integer parameter
is greater than 10.(Nov-17)
12 Which class gives you access to the attribute of a file?(Apr-17) 1
13 Explain usage of class FileInputStream and FileOutputStream by giving an example.(Nov-17) 5
14 Write a program that reads file name from user, through command line argument and displays content 3
of the text file on console. (Dec-18)
15 Write a program to display the bytes of a file in reverse sequence. Provide the name of the file as 7
a command line argument. (Use RandomAccessFile). (June-12)
16 Write a program to count the total no. of chars, words, lines, alphabets, digits, white spaces in a 7
given file. . (Dec-13)
17 Write a program to replace all ―word1‖ by ―word2‖ to a file without using temporary file and 7
display the no. of replacement. (Dec-10, May-18)
18 Write a Java program to copy content of file1.txt to file2.txt using Java file handling. (May-16) 7
19 Create a class called Student. Write a student manager program to manipulate the student 7
information from files by using the BufferedReader and BufferedWriter.(Nov-17)
20 Differentiate between abstract class and Interface. (Dec-14,May-16, Apr-17) 4
21 State whether the following statements are true or false: (Nov-11) 4
(i) An abstract class contains constructors. (T)
(ii) The catch block is the preferred means for releasing resources to prevent resource leaks.(F)
(iii) If capacity increment is not specified for Vector, the system will double the size of Vector each time
additional capacity is needed. (T)
(iv)An interface can extend an abstract class(F)
22 Write a program that illustrates interface inheritance. Interface A is extended by A1 and A2. Interface A12 7
inherits from both P1 and P2.Each interface declares one constant and one method. Class B implements
A12.Instantiate B and invoke each of its methods. Each method displays one of the constants. (Dec-14)
23 The abstract Vegetable class has three subclasses named Potato, Brinjal and Tomato. Write an application that 7
demonstrates how to establish this class hierarchy. Declare one instance variable of type String that indicates the
color of a vegetable. Create and display instances of these objects. Override the toString() method of Object to
return a string with the name of the vegetable and its color. . (Nov-11, May-16)
24 Write a abstract class named Person and its two subclasses named student and Employee. A person has a name, 7
address, phone number and email address. A student has enrolment course. An Employee has an office, salary,
and designation. Define constructors and methods for input and display for both classes. Define constructor and
methods for input and display for both classes. Write a main program to give demonstration of all. (June-19)
25 Explain keywords abstract and volatile.(Dec-15) 2

26 With example explain use of finally in exception handling.(Dec-15)(May-18) 7


27 Write an application that searches through its commandline argument. If an argument is found that does 7
not begin with and upper case letter, display error message and terminate. (Dec-15)
28 Explain use of throw in exception handling with example (Dec-15)(May-17) 7
29 Write an application that reads a file and counts the number of occurrences of digit 5. Supply the file 7
name as a command-line argument.(Dec-15)
30 Explain use of Interface with suitable example. (May-16)(Nov-16) 7
31 Differentiate between interface and abstract class (May-16) 7

OOP-I (3140705) Page 10


Prof. Shital Patel
32 Explain Interface in JAVA. How do interfaces support polymorphism?(May-18) 7
33 Write a method for computing xy doing repetitive multiplication. X and y are of type integer and are to 7
be given as command line arguments. Raise and handle exception(s) for invalid values of x and y (May-
18)
34 Differentiate between Interface and abstract class. When Interface is preferred over abstract class (May- 4
19) (June 19)
35 What do you mean by Interface? Compare interface and abstract class with suitable example. (Nov-18) 7
36 Explain following keywords of java with example. (Nov-18) 7
1) final
2) finally
37 Explain following keywords with example (Nov-18) 7
1) throw
2) throws
38 What is Exception? Demonstrate how you can handle different types of exception separately. (Nov-18) 4
39 What is package? What are the requirements of it? What we can achieve using package?(Nov-18) 4
40 Define exception. List java’s common exceptions. Write a JAVA program to generate and handle 7
division by zero arithmetic exception. (Nov-19)
41 Explain the following terms with respect to exception handling. (Nov-19) 3
i) throw ii) finally
42 Write a program that reads file name from user, through command line argument and displays/reads 3
content of the text file on console.
43 Differentiate between protected and default access specifiers (June 19) 3
44 What do you understand by inner class?(June 19) 3
45 What do you understand by package? Discuss benefits of package(June 19) 3
46 Consider following code fragment: (June 19) 4
try {
statement1;
statement2;
statement3;
}
catch (Exception1 ex1) {
}
finally {
statement4;
}
statement5;
1. Which Statements will execute if no exception is occurs.
2. Which Statements will execute if Exception 1 is occurs at statement
47 Differentiate the followings: (June 19) 7
1. Checked and Unchecked Exceptions
2. Socket and ServerSocket
3. Text I/O and Binary I/O
4. String and StringBuffer
48 What is Interface? Write steps to declare and define an interface and explain with sample 7
program.(Dec-19)
49 Explain try, catch, throw, throws and finally in detail (Dec-19) 7
50 What is Stream Class? Explain input stream class and output stream class in details. (Dec-19) 7

OOP-I (3140705) Page 11


Prof. Shital Patel
51 What is exception? List out and explain the keywords used to handle exceptions.(Dec-20) 7
52 What are interfaces in java? How do they support polymorphism?.(Dec-20) 4
53 What is garbage collection? What is the roll of finalize () in it?(Dec-20) 4
54 Differentiate checked exceptions with unchecked exceptions (Dec-20) 3
55 What is runnable interface? How can you use this interface in creating thread?(Dec-20) 4
56 Write a java program to explain the use of File class and its methods.(Dec-20) 7
57 Differentiate abstract class with interface(Dec-20) 3
58 What are the wrapper classes? Explain the use of any one wrapper class (Dec-20) 3
59 What are the uses of ‘final’ keyword? Write a java program to explain all of them. 7
60 Define Character Stream, Byte Stream, Input Stream Reader class, Buffered Reader class 4
61 Explain the Reader and Writer classes along with some of its methods. 4
62 Explain File constructors, any two methods of class File and method seek. 7
63 Explain the File class with all its important methods. 7
64 How we can read input from web? Demonstrate with one java example. 7
65 Why do we need a catch block? Explain the principles with which you can use the catch block. 4
66 Why do we make use of try blocks in programs? 3
67 Explain comparable interface and cloneable with example. 7

UNIT- 7 (Chapter 14,15) JAVAFX basics and Event-driven programming and animations
1 What interface defines (i) binding property (ii) source object. 3
2 What is a binding property? Explain 3

3 How do you display a stage? How to prevent the user from resizing the stage? 3
4 How to set a style of a node with border color red and to set the text color for the button to red. Demonstrate 3
with code.
5 How to set a circle object c with blue fill color using the setFill method and using the setStyle method? 3
6 How to create a color? How to create a Color object with a random color? 3
7 How to rotate a pane, a text, or a button? Write the code to rotate the button 15 degrees counterclockwise? 3
8 What is a unidirectional binding and what is bidirectional binding? Write a statement to bind property d1 with 3
property d2bidirectionally
9 What are the binding object types for int, long, float, double, and boolean? 3
10 How do you set circle‘s stroke color and fill color? 3
11 What is a pane? What is a node? How do you place a node in a pane? 3
12 How do you create a Scene object? How do you set a scene in a stage? 3
13 How to create an ImageView from an Image, or directly from a file or a URL? 3
14 How do you define a JavaFX main class? What is the signature of the start method? 3
15 Following the JavaFX binding property naming convention, for a binding property named age of the 4
IntegerPropertytype, what is its value getter method, value setter method, and property getter method?
16 What is the column and row index of a node in a GridPane? How do you reposition a node in a GridPane? 7
17 Explain how set an Image to multiple ImageView? Is it possible to display the same ImageView multiple times? 7

18 How to find all available fonts on your system? Write a code to create a Font object with font name Courier, size 7
20, and weight bold?

OOP-I (3140705) Page 12


Prof. Shital Patel
19 Write code fragments to display a thick line of 10 pixels from (10, 10) to (70, 30). 7
20 Write code fragments to display (i) the outline of the upper half of a circle with radius 50. (ii) the lower half of a 7
circle with radius 50 filled with the red color.
21 Write code fragments to display a round-cornered rectangle with width 100, height 200 with the upper-left 7
corner at (10, 10), corner horizontal diameter 40, and corner vertical diameter 20
22 Write code fragments to display a polygon connecting the following points: (20, 40), (30, 50), (40, 90), (90, 10), 7
(10, 30), and fill the polygon with green color.
23 Write a program that draws two circles with radius 15 pixels, centered at random locations, with 7
a line connecting the two circles.
24 Write a program that displays three cards randomly selected from a deck of 52, as shown in Figure (c). The card 7
image files are named 1.png, 2.png, ..., 52.png and stored in the image/card directory. All three cards are distinct
and selected randomly.
25 Write a program that displays a tic-tac-toe board, as shown in Figure (b) . A cell may be X, O, or empty. What 7
to display at each cell is randomly decided. The X and O are images in the files x.gif and o.gif
26 Write a program that displays four images in a grid pane, as shown in Figure (a) 7

27 Write a program that displays five texts vertically, as shown in Figure (a). Set a random color and 7
opacity for each text and set the font of each text to Times Roman, bold, italic, and 22 pixels.
28 Write a program that displays a string Welcome to Java around the circle, as shown in Figure (b) 7
Hint: You need to display each character in the right location with appropriate rotation using a loop
29 Write a program that displays a checkerboard in which each white and black cell is a Rectangle 7
with a fill color black or white, as shown in Figure (c)

31 What is a lambda expression? What is the benefit of using lambda expressions for event handling? What is the 3
syntax of a lambda expression?
32 What is a functional interface? Why is a functional interface required for a lambda expression? 3
33 What methods do you use to register a handler for a mouse pressed, released, clicked, entered, exited, moved 3
and dragged event?
34 Explain: MouseEvent, KeyEvent, ActionEvent 3
35 Why must a handler be an instance of an appropriate handler interface? 3
OOP-I (3140705) Page 13
Prof. Shital Patel
37 How to set focus on a node so it can listen for key events? 3
38 How to set the cycle count of an animation to infinite? 3
39 How to start, pause, and stop an animation? 3
40 How to auto reverse an animation? 3
41 What is an event source object? What is an event object? Describe the relationship between an event source 4
object and an event object
42 If class A is an inner class in class B, what is the .class file for A? If class B contains two anonymous inner 4
classes, what are the .class file names for these two classes?

43 Explain how to register a handler object and how to implement a handler interface. 7
44 Explain How to create PathTransition, FadeTransition, Timeline, KeyFrame 7
45 What methods used to register handlers for key pressed, key released, and key typed events? In which classes 7
are these methods defined?
46 Write a program that rotates a rectangle 15 degrees right when the Rotate button is clicked. 7
47 Explain Label and Button class and their methods in detail. (Dec-19) 7
48 Write a program that displays a moving text. The text moves from left to right circularly. When it disappears in 7
the right, it reappears from the left. The text freezes when the mouse is pressed and moves again when the
button is released.
UNIT- 8 (Chapter 16) JAVAFX UI controls and multimedia

1 Write a program controls and plays a video. 7

2 Write a program that draws various figures, as shown in Figure (a). The user selects a figure from a 7
radio button and uses a check box to specify whether it is filled.

3 Write a program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or 7
green. When a radio button is selected, the light is turned on. Only one light can be on at a time (see Figure (b)).
No light is on when the program starts.
4 (Create a miles/kilometers converter) Write a program that converts miles and kilometers, as shown in Figure 7
16.37b. If you enter a value in the Mile text field and press the Enter key, the corresponding kilometer
measurement is displayed in the Kilometer text field. Likewise, if you enter a value in the Kilometer text field
and press the Enter key, the corresponding miles is displayed in the Mile text field.

OOP-I (3140705) Page 14


Prof. Shital Patel
5 (Convert numbers) Write a program that converts between decimal, hex, and binary numbers, as shown in 7
Figure 16.37c. When you enter a decimal value in the decimalvalue text field and press the Enter key, its
corresponding hex and binary numbers are displayed in the other two text fields. Likewise, you can enter values
in the other fields and convert them accordingly. (Hint: Use the Integer.parseInt(s, radix) method to parse a
string to a decimal and use Integer.toHexString(decimal) and Integer.toBinaryString(decimal) to obtain a hex
number or a binary number from a decimal.)

UNIT- 9 (Chapter 17,18,19) Binary I/O ,Recursion and Generics

1 Explain usage of class FileInputStream and FileOutputStream by giving an example. (Nov-17) 3


Write a program to read the content of a file into a character array and write it into another file. Get names of the 7
files from command line.
2 What is Text I/O, and Binary I/O? List Binary I/O classes. 3
3 Compare byte streams and character streams. 4
4 Explain FileInputStram and FileOutputStream with example. 7
5 Explain BufferedInputStram and BufferedOutputStream with example. 7
6 Explain DataInputStram and DataOutputStream with example. 7
7 Explain Object I/O classes, ObjectInputStram and ObjectOutputStream with example. 7
8 Explain RandomAccessFile with example. 7
9 Write a program to create a file named example.dat if it does not exist. Append new data to it if it already exists. 7
Write 100 integers created randomly into the file using binary I/O.
11 Explain Recursive Helper method with example. 3
12 Differentiate between recursion and iteration. 3
15 Implement recursive selection sort. 7
16 Implement recursive bubble sort. 7
17 Write the program for factorial using the concept of recursion. 7
18 What is the advantage of using Generic? 3
19 How to define Generic class and interface explain with example. 3
20 How to use Generic methods show it with example. 4
21 Explain Raw types and backward compatibility with example. 7
22 Explain wildcard Generic type with example. 7
23 Explain Erasure and Restrictions on generics with example. 7

24 Implement stack using Generic class. 7


25 Implement sorting of an array of comparable object using Generic Method. 7
UNIT- 10(Chapter 20) List, Stacks, Queues and Priority Queues

OOP-I (3140705) Page 15


Prof. Shital Patel
1 Write a note on Collection in JAVA‘. Also discuss List and Enumeration Interface. (Nov-17) 4
What is Collection in Java? Explain the use of Iterator (Dec-20) 3
2 Explain utility class ArrayList and Hashtable with example (May-13, Dec-15) 7
3 Describe the Java Collections Framework. (June-14) 7
4 List the interfaces, abstract classes and concrete classes of collection hierarchy. (Nov-11) 7
5 Write a complete program to implement a singly linked list with nodes storing integer information using suitable 7
utility class. (Dec-15)
6 Explain use of Linked List collection class with example. (Dec-15) 7
7 What do you understand by Collection framework in java? List methods available in iterator interface. (June 3
19)(May-19)
8 What is the difference between Set and Map? 3
9 What is the difference between HashSet and HashMap? 3
10 What is the difference between Iterator, ListIterator and Enumerator? 4
11 What is the difference between ArrayList, LinkedList and Vector? 4
UNIT- 11(Chapter 21) Sets and Maps

1 Explain the unique features of Map interface.. (Jan-13,June-14,Dec-14) 3


2 What are the differences between HashSet, LinkedHashSet, and TreeSet 7
3 How do you create an instance of Set? How do you insert a new element in a set? How do you remove an 7
element from a set? How do you find the size of a set?
4 How do you sort the elements in a set using the compareTo method in the Comparable interface? How do you 7
sort the elements in a set using the Comparator interface? What would happen if you added an element that
could not be compared with the existing elements in a tree set?
5 Write a program for each word in a Java source file, we need to determine whether the word is a keyword. To 7
handle this efficiently, store all the keywords in a HashSet and use the contains method to test if a word is in the
keyword set.
6 How do you create an instance of Map? How do you add an entry to a map consisting of a key and a value? 7
How do you remove an entry from a map? How do you find the size of a map? How do you traverse entries in a
map?
7 Describe and compare HashMap, LinkedHashMap, and TreeMap 7
8 Write a program that counts the occurrences of words in a text and displays the words and their occurrences in 7
alphabetical order of the words. [hint: a TreeMap to store an entry consisting of a word and its count]
UNIT- 12 Concurrency

1 Explain multi threading in java using example. (Dec-15) 7

2 What are the methods to create thread? Write a multithraded program to explain the use of join() method. (May- 7
17)
3 Explain Thread life cycle and describe creation of thread with suitable example.(May-16) 7
4 What do you understand by thread? Describe the complete life cycle of thread. (May-19) 4
5 Explain use of following methods with suitable example isAlive(), join(), setPriority(). (Nov-18) 7
6 What is multithreading? What are the ways in which you can create a thread? Explain with Example. (Nov-18) 2
7 Differentiate multithreading and multiprocessing.(Nov-19) 3
8 Draw and Explain Thread Life Cycle(Nov-17) 4
9 What are the different ways to create thread? Explain with example. (Nov-17) 7
11 Explain use of following methods with suitable example isAlive(), join(), setPriority(). (Dec-18) 7
12 What is the effect of adding the synchronized keyword to a method?(Apr-17) 1
OOP-I (3140705) Page 16
Prof. Shital Patel
13 List and Explain Methods for Inter-thread communication (cooperation).(Nov-17) 2
14 Explain two usage of keyword synchronized. (Dec-15) 2
15 What is a thread? Describe the complete life cycle of thread. (Nov-19) (Nov-19) 4
16 Discuss the role of thread synchronization in inter-thread communication? Explain with example.(Nov-19) 7
17 Why synchronization is required in multithreaded programming. Write a program that uses 4
thread synchronization to guarantee data integrity in a multithreaded application.(Jan-13)
18 Explain wait, notify, synchronized and native methods. (May-13) 5
19 Write an application that creates and starts three threads. Each thread is instantiated from the same class. It 7
executes a loop with 10 iterations. Each iteration displays string "HELLO", sleeps for 300 milliseconds. The
application waits for all the threads to complete & displays the message "Good Bye..." (Dec-13)
20 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. ith row of the matrix is
processed by ith thread. Where 0 <= i< m.
- Print the results. . (June-11)
21 Write an application that executes two threads. One thread displays "Good Morning" every 1000 milliseconds & 7
another thread displays "Good Afternoon" every 3000 milliseconds. Create the threads by implementing the
Runnable interface. (Dec-13, Nov-16, May-18)
22 Draw and explain the life cycle of thread in detail. (Dec-19) 7
23 Write a program of writing binary file using multithreading. Demonstrate use of join() and yield(), interrupt(). 7
(Dec-10)
24 Write a program to create two threads, one thread will check whether given number is prime or not and second 7
thread will print prime numbers between 0 to 100. (May-18)
25 Write a program to create two thread one display alphabet from a to z and other will display numbers from 1 to 7
100. (June-19)
26 Write a complete multi threaded program to meet following requirements for producer-consumer threads: 4
- Three threads – one producer and two consumers to be instantiated in the method main.
- At a time, the producer produces one integer information along with consumer_id to represent id of a
consumer that will consume produced information.
- Information and consumer_id are stored in a shared buffer. - The information produced is to be consumed by
appropriate consumer only, as specified by the producer.
- The producer thread produces total 6 information.(May-16)
27 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.
o Both producers produce information for both consumers.
28 Explain the variable for Thread Priority. 3
29 What id Interprocess Communication and Inter Thread Communication? Take a realtime example and explain it. 4

OOP-I (3140705) Page 17


Prof. Shital Patel

You might also like