Professional Documents
Culture Documents
Oopj Que Bank
Oopj Que Bank
UNIT -5 Package
1. Write a multithreaded program to compute and print prime numbers up to n where n i given
as command line argument. Instantiate requited number of threads where eac thread except
the last, examines next 50 numbers and the last thread examines remainin numbers to check
whether number is a prime or not.(Winter 2015)
2. Explain dynamic method dispatch by giving an example.(Winter 2016)
3. Declare a class called author having author_name as private data member. Extend author
class to have two sub classes called book_publication&paper_publication. Each of these
classes have private member called title. Show usage of dynamic method dispatch (dynamic
polymorphism) to display book or paper publications of a given author. Use command line
arguments for inputting data.(Summer 2017)
4. Write a complete program to have 3 Buttons in a frame having exit capabilities. Buttons are
to be added in the frame as per the layout of your choice. Count and display number of
times each Button being clicked.
5. Explain package and its use with appropriate example(Winter 2017)
1. Explain Thread Life Cycle in detail. Write a code to create Thread in JAVA. (Winter 2015)
2. What is multithreading? Why it is required? Write a program that creates three threads.
Make sure that the main thread executes last.(Summer 2016)
3. Explain wait, notify, synchronized and native methods.(Summer 2016)
4. Write a complete multi threaded program to meet following requirements for producer-
consumer threads: ).(Winter 2017)
a. Three threads – one producer and two consumers to be instantiated in the
method main.
b. At a time, the producer produces one integer information along with
consumer_id to represent id of a consumer that will consume produced
information.
c. Information and consumer_id are stored in a shared buffer.
d. The information produced is to be consumed by appropriate consumer only, as
specified by the producer.
e. The producer thread produces total 6 information.
5. List and Explain Methods for Inter-thread communication (cooperation).(Winter 2017)
UNIT -8 IO Programming
1. Text I/O v/s Binary I/O. OR Character I/O v/s Byte I/O. (Winter 2015)
2. Explain File constructors, any two methods of class File and method seek. (Summer
2016)
3. Write a program to check that whether the name given from command line is file or
not? If it is a file then print the size of file and if it is directory then it should display
the name of all files in it.(Summer 2016)
4. Write a program that counts the no. of words in a text file. The file name is passed as a
command line argument. The program should check whether the file exists or not. The
words in the file are separated by white space characters.
5. Write a program to display the bytes of a file in reverse sequence. Provide the name of the
file as a command line argument. (Use Random_Access_File)
6. 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.
7. Write a program to replace all “word1” by “word2” from a file1, and output is written to
file2 and display the no. of replacement.
8. Write a program to count the total no. of chars, words, lines, alphabets, digits, white spaces
in a given file.
9. Explain usage of class FileInputStream and FileOutputStream by giving an
example.(Winter 2017)
1. Draw state diagram for Book Issue process in Library Management System. (Winter
2015)
2. Draw state diagram for Book Issue process in Online Ticket reservation System.
(Winter 2016)
3. What is a one shot state diagram? Draw one shot state for chess game with entry and
exit points.
4. Define Event, State and Transition. Using example draw state diagram.
5. Differentiate state and event. List different types of events.
6. Prepare a class model to describe undirected graph. An 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.
7. Explain Metadata with the help of an example.
8. Develop the State Machine diagram for Blood Donation Management System.
1. Draw Use Case Diagram for Online Ticket Reservation System. (Summer 2015)
2. Draw Use Case Diagram for ATM. (Summer 2015)
3. Draw Use Case Diagram for Online Shopping. (Winter 2016)
4. Draw Use Case Diagram for Library Management System. (Winter 2016)
5. Prepare sequence diagram for booking a train ticket on line. Also Prepare sequence
diagram for booking a train ticket on line that fails.
6. Prepare sequence diagram for withdraw amount from ATM.
7. Prepare sequence diagram for shopping online.
8. Prepare sequence diagram for Issue or Return book in library.
9. Prepare an Activity diagram for Online Ticket Reservation System.
10. Prepare an Activity diagram for withdraw amount from ATM.
11. Prepare an Activity diagram for Online shopping.
12. Prepare an Activity diagram for Issue or return book in Library.
13. Develop the Activity and Seaquence diagram for Blood Donation Management System
Programs (Winter 2017 ,Winter-2016, Winter 2015 & Summer-2015, Summer 2016 ,Summer
2017, Summer 2018)
1. Write a complete program to accept N integer numbers 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
2. Skip the number if an exception is raised for it, otherwise add it to find total sum.
3. Write a complete program to read from console up to n 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.
4. Declare a class called Coordinate to have 3 dimensional Cartesian coordinates. Define
following methods :
- Constructor(s)
- add_coordinates to add two Coordinate objects and to produce resultant object. Generate
and handle exception if all three coordinates of the resultant Coordinate object are zero.
5. Define method main to show use of above methods.
6. Write a complete program to implement a singly linked list with nodes storing integer
information using suitable utility class.
7. Write a multithreaded program to print all odd positive numbers in ascending order up to n,
where n is a positive integer number given as a 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 up to n.
8. Write a multi-threaded program to have two producer threads, each writes (push) total 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
required conditions so that all valid items are popped only once and there is no stack
overflow & underflow.
9. Write a program that creates and initializes a four integer element array. Calculate and
display the average of its values
10. Write a java program to do sum of command line argument passed two Double numbers
11. Define time class with hour and minute. Also define addition method to add two time
objects
12. Write a program to create circle class with area function to find area of circle.
13. Write an application that searches through its command-line argument. If an argument is found
that does not begin with and upper case letter, display error message and terminate.
14. Write an application that reads a file and counts the number of occurrences of digit 5. Supply
the file name as a command-line argument
15. Declare a class called Book having book title & author 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 by author name / book title
- To update stock of a book on purchase and sell
-Define method main to show usage of above methods.
16. It is required to compute SPI (semester performance index) 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
17. 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
18. It is required to maintain and process the status of total 9 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.
19. Write a method for computing first n terms of Fibonacci sequence. Define method main taking
value of n as command line argument and calling the method.
20. Write a complete program to accept N integer numbers 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.
21. Write a multithreaded program to compute and print prime 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.
22. Write a complete program to read from console up to n 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.
23. Write a complete multi threaded program to meet following requirements for producer-
consumer 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.
24. Create a class called Student. Write a student manager program to manipulate the student
information from files by using the BufferedReader and BufferedWriter.
25. Write a program for chat application using TCP
26.Write a program to find whether the given string is palindrome or not.