Sunteți pe pagina 1din 10

OOPUJ-2150704

GTU Question Bank

Unit #1 – Basics of Java


No Question Marks Year
1. Discuss benefits of Object Oriented 3 2019-S
Approach?
2. Explain short circuited operator with example. 4 2018-S
3. Compare Object oriented programming with sequential 3 2018-S
programming.
4. What is command line arguments? Write a java program to 3 2017-S
read a line from command line input and prints a reverse of
it
5. What will be the result of following expression? 4*2-5>4 1 2017-S
&& 3<5-3
6. What are the basic four integer types supported by Java ? 1 2016-W
7. Explain role of JVM 1 2016-W
8. The method main is a static method. Why? 1 2016-W
9. Explain method parseInt. 1 2016-W
10. Explain Features of Java. 7 2016-S

Unit #2 – Array and Strings


No Question Marks Year
1. Write a program that counts number of characters, words, 7 2019-S
and lines in a text file.
2. Write a program to take three numbers as command line 4 2019-S
argument. Display the maximum among them?
3. What are Wrapper classes? What is Autoboxing? 3 2019-S
4. Differentiate between final, finally and finalize. What will 7 2018-W
happen if we make class and method as final?
5. Write a program which takes five numbers as command 4 2018-W
line argument from user, store them in one dimensional
array and display count of negative numbers.
6. Differentiate: String and StringBuffer Class 2/3 2018/17-S
2016-W
7. Write a program to find whether the given string is 3 2017-W
palindrome or not.
8. What will be the output of following code snippet? 3 2017-S/W
(1) class evaluate {
public static void main(String args[])
{
int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 6;
n = arr[arr[n] / 2];
System.out.println(arr[n] / 2);
}
}
(2) class equality {
int x;
int y;
boolean isequal() {
return(x == y);
}
}
class Output {
public static void main(String args[])
{
equality obj = new equality();
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal());
}
}
9. Create two dimensional array named ‘marks’ initialize it ? 1 2017-S
10. Write a complete program to read from console up to n 7 2016-W
lines or until “quit” is entered. The lines entered are
displayed on the screen after reading all lines. The program
also counts lines beginning with character ‘A’ or ‘E’ as first
letter.
11. Write a method for computing first n terms of Fibonacci 4 2016-W
sequence. Define method main taking value of n as
command line argument and calling the method
12. How do you interpret following statement? String [] s; 1 2016-W
13. Explain right-shift operators 1 2016-W
14. Write a complete program to read from console up to n 7 2016-S
lines or until “quit” is entered. The lines entered are
displayed on the screen after reading all lines. The program
also counts lines beginning with character ‘A’ or ‘E’ as first
letter.
15. Write a method for computing first n terms of Fibonacci 4 2016-S
sequence. Define method main taking value of n as
command line argument and calling the method.
Unit #3 – Class, Object and Methods
No Question Marks Year
1. Justify: 1. Why we declare main() method as public and 7 2019-W
static member.
2. Why we generally declare constructor as public member.
3. Why there is no destructor in java.
2. Write a class named Rectangle to represent a rectangle. It 7 2019-S
contains following members:
Data: width (double) and height (double) that specify the
width and height of the rectangle.
Methods: 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
3. When will you declare a method as a static? Explain static 3 2018-W
method with suitable example
4. Differentiate between protected and default access 3 2018-W
specifiers.
5. Explain following terms with example: (A) Nested 7 2018-S
Class (B) Anonymous Inner Class
6. Write a program which shows an example of function 7 2018-S
overriding.
7. Write a program which shows an example of function 7 2018-S
overriding
8. Differentiate between constructor and method of a class. 3 2018-S
9. What is constructor? Explain constructor overloading with 4 2017-W
example.
OR
What do you mean by Overloading? Explain constructor
overloading with suitable example.
10. Differentiate between Method overloading and Method 4 2017-W
overriding
11. Discuss public, private and protected access modifiers. 3 2017-W
12. It is required to compute SPI (semester performance index) 7 2016-W
of n students of a class for their registered subjects 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
Unit #4 – Inheritance and Interface
No Question Marks Year
1. Explain dynamic method dispatch by giving an example 3 2019-S /
/2018-
W/2017-
W/2016-W
2. Write an abstract class named Person and its two subclasses 7 2019-S
named Student and Employee. A person has 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.
3. Explain Interface in JAVA. How do interfaces support 7 2018-S
polymorphism?
4. Explain interface and its usage. 3 2017-W
5. Explain different uses of ‘super’ keyword with the help of 7 2017-S
Java Program.
6. What is the purpose of ‘this’ and ‘static’ keyword with in 4 2017-S
Java? Write a program to explain this.
7. Differentiate: Class and Interface 2 2017-S
8. Explain use of Interface with suitable example. 7 2016-W
9. Declare a class called Book having book title & author 7 2016-W
name as members. Create a sub-class of it, called
BookDetails having price & current stock of book as
members. Create an array for storing details of n books.
Define methods to achieve following: - Initialization of
members - To query availability of a book byauthor name /
book title - To update stock of a book on purchase and sell
Define method main to show usage of above methods.
10. Explain instanceof operator. 3 2016-W
11. The abstract vegetable class has three subclasses named 7 2016-S
Potato, Brinjal and Tomato. Write a java prog. That
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.
12. Describe Inheritance and its type with suitable example 7 2016-S
13. Differentiate between interface and abstract class. 7 2016-S
OR
Differentiate between Interface and abstract class. When
Interface is preferred over abstract class.
Unit #5 – Package
No Question Marks Year
1. Define:Package 1 2019-W
2. What do you understand by package? Discuss benefits of 3 2019-S/
package. 2017-W
OR
What is package? What are the requirements of it? What
we can achieve using package?
3. Explain keywords private and protected. 4 2018-S
4. Explain different Visibility modifiers 3 2018-S
5. What is a CLASSPATH? Explain it by giving example. 3 2017-S
6. Describe use of CLASSPATH 1 2016-W
7. Write use of keyword import. 1 2016-W

Unit #6 – Exception Handling


No Question Marks Year
1. Consider following code fragment: 4 2019-S
try {
statement1;
04
2
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 2.
2. Write a method for computing x^y doing repetitive 7 2018-S/
multiplication. X and y are of type integer and are to be 2016-S
given as command line arguments. Raise and handle
exception(s) for invalid values of x and y.
OR
Define a recursive method for computing x raised to power
y by doing repetitive multiplication where x and y are
positive integer numbers. Define main to use above
method.
3. What is Exception? Demonstrate how you can handle 4 2018-W
different types of exception separately.
4. Explain use of finally in exception handling. 4 2018-S
5. Differentiate- Checked and Unchecked exceptions 2 2018-S
6. Explain the importance of exception handling in java. 7 2017-W
Which key words are used to handle exceptions? Write a
program to explain the use of these keywords.
7. Draw and Explain Thread Life Cycle. 4 2017-W
8. Discuss exception and error. 3 2017-W
9. When do we use throws statement? Explain it by giving 4 2017-S
example.
10. Which class is at the top of the exception hierarchy? 1 2017-S
11. It is required to maintain and process the status of total 9 7 2016-W
resources. The status value is to be stored in an integer
array of dimension 3x3. The valid status of a resource can
be one of the followings:free: indicated by integer value 0
occupied: indicated by integer value 1 inaccessible:
indicated by integer value 2 Declare a class called
ResourcesStatus, having data member called statusRef,
referring to a two dimensional array (3x3) of integers to be
used to refer to the above mentioned status values. Define a
member method called processStausCount that counts and
displays total number of free resources, total number of
occupied resources and total number of inaccessible
resources. The exception to be raised and handled if total
number of occupied resources exceeds total number of free
resources. The handler marks status of all inaccessible
resources as free. Accept initial status values from
command line arguments and initialize the array. Raise and
handle user defined exception if invalid status value given.

12. Write a complete program to accept N integer numbers 7 2016-W


from the command line. Raise and handle exceptions for
following cases: - when a number is –ve - when a number
is evenly divisible by 10 - when a number is greater than
1000 and less than 2000 - when a number is greater than
7000 Skip the number if an exception is raised for it,
otherwise add it to find total sum
Unit #7 – Multithreaded Programming
No Question Marks Year
1. Write a program to create two thread one display alphabet 4 2019-S
from a to z and other will display numbers from 1 to 100.
2. What do you understand by thread? Describe the complete 4 2019-S
life cycle of thread.
3. What is multithreading? What are the ways in which you 7 2018-W
can create a thread? Explain with Example
4. Explain use of following methods with suitable example 7 2018-W
isAlive(), join(), setPriority().
5. Write a program to create two threads, one thread will 7 2018-S
check whether given number is prime or not and second
thread will print prime numbers between 0 to 100
6. List and Explain Methods for Inter-thread communication 3 2017-W
(cooperation).
7. What are the two methods to create threads? Write a 7 2017-S
multithread program to explain use of join() method.
8. Write a multithreaded program to compute and print prime 4 2016-W
numbers up to n where n is given as command line
argument. Instantiate requited number of threads where
each thread except the last, examines next 50 numbers and
the last thread examines remaining numbers to check
whether a number is a prime or not.
9. Write a complete multi-threaded program to meet following 4 2016-W
requirements for producerconsumer threads: - 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.
10. Explain Thread life cycle and describe creation of thread 7 2016-S
with suitable example.
Unit #8 – File I/O
No Question Marks Year
1. Differentiate the following: A. Text I/O and Binary I/O 2 2019-
S/2018-S
2. Write a java program to search file named the word entered 7 2018-
as filename from command line; if it exists in the system W/2017-S
then program should print the content of the file on console.
3. Write a program to check whether the name given from 7 2018-S
command line is file or not? If it is a file then print the size
of a file and if it is a directory then it should display the
name of all files in it
4. Write a program using BufferedInputStream, 7 2018-S
FileInputStream, BufferedOutputStream, FileOutputStream
to copy content of one file Test1.txt into another file
Test2.txt
5. Explain usage of class FileInputStream by giving an 3.5 2017-
example W/2016-W
6. Create a class called Student. Write a student manager 7 2017-W
program to manipulate the student information from files
by using the BufferedReader and BufferedWriter.

Unit #9 – Collections
No Question Marks Year
1. What do you understand by Collection framework in java? 3 2019-S
List methods available in iterator interface.
2. What is java collection framework? What are the benefits 3 2018-W
of the java collection framework?
3. Explain use of Linked List collection class with example. 7 2018-S
4. What is collection in Java ? List out various methods of 3 2017-S/W
List and Enumeration Interface.
5. Explain ArrayList 1 2016-W

Unit #10 – Networking with java.net


No Question Marks Year
1. Explain InetAddress class and its one method. 3.5 2016-W
2. Write a program for chat application using TCP. 7 2017-W
3. Write a program that accepts name of website from user, 3 2018-W
and displays IP address of it on console.
4. State difference between DatagramSocket and 3 2018-S
DatagramPacket.
5. Explain Metadata with the help of an example 3 2016-S
Unit #11– Introduction to OOAD
No Question Marks Year
1. What is UML? Explain Class Model, State Model and 4 2018-W
Interaction Model in brief.
2. What is UML? How it is useful? 3 2018-S /
2017-S
3. What is modelling? Explain the purpose of modelling. 3 2017-S

Unit#12/13 – Class Diagram


No Question Marks Year
1. Define: 7 2019-S /
1. Association 2017-W /
2. Aggregation 2017-S
3. Metadata
4. Constraints
5. Package
6. Multiplicity
7. Qualified Association
OR
Define the following terms: Aggregation, Abstract Class,
Generalization, Rectification, Constraints, Package,
Metadata, derived data.
2. Draw class diagram of bank management system. 7 2018-W
3. Explain generalization in class diagram with example. 4 2018-W
4. Explain ‘ordered’, ‘bags’ and ‘sequences’ in class diagram 3 2018-S
5. Discuss link and association in UML with diagram. 4 2017-W
6. Prepare a class model to describe undirected graph. An 4 2016-W
undirected graph consists of a set of vertices and a set of
edges. Edges connect pairs of vertices. Your model should
capture only structure of graphs (i.e. connectivity) and need
not be concerned with layout such as location of vertices or
lengths of edges.
Unit #14 – State Diagram
No Question Marks Year
1. Explain state diagram with example 3 2019-S
2. What is use of fork and join in activity diagram? Explain 3 2018-W
with suitable example.
3. Draw a state model for Telephone Line system. 4 2018-S
4. Explain activity diagram with the help of an example. 7 2017-W /
2016-W
5. Explain Nested States. Draw the Nested states diagram for 7 2017-W
the phone line.
6. What is the purpose of state modelling? Explain briefly the 7 2017-S /
elements of state modelling. Prepare a state model for 2016-W
Telephone Line system.
7. Explain the following terms: event, state, transition, and 4 2017-S
condition.

Unit #15 – Interaction Diagram


No Question Marks Year
1. Draw the use case diagram of Library management system. 4 2019-S /
2017-W
2. Write a sequence diagram of ATM withdrawal process. 4 2019-S
3. Draw use case diagram for hotel management system. 7 2018-W
4. What is usefulness of sequence diagram? List components 3 2018-W
of it.
5. What is Interaction modeling? Explain briefly usage of Use 7 2018-S
case model. Prepare a Use case model for Telephone Line
system.
6. Prepare an activity diagram for Online Bus ticket booking 4 2018-S
system.
7. Explain activity diagram with the help of an example. 7 2017-W /
2016-W
8. Draw sequence diagram for book issue process of library. 4 2017-W
9. List out the purpose of interaction modes. 3 2017-S
10. Explain sequence diagram with the help of an example. 7 2016-W

S-ar putea să vă placă și