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/ 10
Object Oriented Programming-I (3140705)
Question Bank
Year: 2022-2023
Prepared by: Dr. Viral A. Parekh
Question Bank Marks CO
UNIT- 1 Introduction to java and elementary Programming
1. Explain JRE, JDK and JIT (Summer-20). 03 CO1
2. Discuss significance of byte code. (Winter-22) 03 CO1 3. Compare object-oriented programming with procedural oriented language? (Summer- 03 CO1 20, Winter-20). 4. Explain Java garbage collection mechanism. (Winter-22) 04 CO1 5. List OOP characteristics and describe inheritance with examples. (Summer-21, Winter- 03 CO1 22) 6. Explain Data Types in detail with example. (Winter-21) 07 CO1 7. What is Type Casting? Explain widening and narrowing type casting. (Winter-20, 04 CO1 Winter-21). 8. With a neat diagram explain the Model view controller design pattern and list out the 07 CO1 advantages and disadvantages of using it in designing an application. (Summer-21) 9. What are the data-types and operators available in Java? (Winter-20). 07 CO1 10. List out features of Java. Explain any two features. (Summer-22). 03 CO1 11. What are syntax errors (compile errors), runtime errors, and logic errors? (Winter-21) 03 CO1 12. There is no destructor in Java. Justify. 01 CO1 13. Explain short circuited operators and shift operators in Java. 04 CO1 14. Java program is to be compiled first and then to be interpreted for execution. True or 04 CO1 false? Justify your answer. 15. Draw and explain the process of building and running JAVA Program.(Dec-19) 07 CO1 16. Explain the concept of finalization. (Summer-21) 03 CO2 17. Why java is preferred as a programming language for Internet? 03 CO1 UNIT- 2 Selections, Mathematical functions and loops 18. Write a java program to print prime number up to 100. 03 CO2 19. Difference between Nested if and multi-way if statements. (Winter-20) 03 CO2 20. Write a JAVA program to implement the Fibonacci series using for loop control structure. 07 CO2 21. Write a program to print multiplication table in java of user entered number. 07 CO2 22. Write a program that prompts the user to enter two positive integers and finds their greatest 07 CO2 common divisor. 23. Write a program that prompts the user to enter a three-digit integer and determines whether 07 CO2 it is a palindrome number. A number is palindrome if it reads the same from right to left and from left to right. UNIT- 3 Methods and Arrays 24. Explain about arrays, Type of arrays and arrays methods. 03 CO2 25. Explain the following: (Summer-22, Winter-21) 04 CO2 i) Arguments and Parameters of a function ii) Pass by Value and Pass by reference 26. Create two dimensional array named marks‘ and initialize it. 03 CO2 27. Explain Ragged Array With example. 03 CO2 28. Write a problem is to read 100 numbers get the average of these numbers, and find the 07 CO2 number of the items greater than the average. 29. Write a JAVA program to display the following output using 2-D array. 07 CO2 0 12 345 6789 30. Write a program that creates and initializes a four integer element array. Calculate and 07 CO2 display the average of its values. 31. Write a java program to do sum of command line argument passed two Double numbers. 07 CO2 32. Write a method for computing first n terms of Fibonacci sequence. Define method main 04 CO2 taking value of n as command line argument and calling the method. 33. Write a program which takes five numbers as command line argument from user, store 04 CO2 them in one dimensional array and display count of negative numbers. 34. Write a JAVA program to create a super class called figure that stores the dimensions of 07 CO2 a two- 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. 35. With the help of program show how to pass object as an argument of method. 07 CO2 36. Write a java program to take infix expressions and convert it into prefix expressions. 07 CO2 (Summer-22) UNIT- 4 Objects and Classes 37. Explain about Encapsulation, Abstraction. (Summer-21) 04 CO1 38. Explain super and static keyword with example. (Summer-20, Winter-20) 04 CO2 39. Explain class and object with respect to java. (Winter-20) 07 CO2 40. Define Encapsulation and access specifier. (Summer-22, Winter-20) 03 CO2 41. When will you declare a method as a static? Explain static variable and static method with 04 CO2 example. 42. What is constructor? Explain constructor overloading. (Winter-20, Winter-21) OR 07 CO2 Define constructor. How objects are constructed? Explain constructor overloading with an example. (Summer-21) 43. How to access object via reference variable? Explain with example. (Winter-20) 04 CO2 44. List and explain available type of constructors in java with example. (Winter-20, Winter- 07 CO2 22) 45. Define time class with hour and minute. Also define addition method to add two time 07 CO2 objects. 46. Differentiate the followings: Constructor and method. 03 CO2 47. It is required to compute SPI (semester performance index) of n students of a class for 07 CO2 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. 48. Write a class named Rectangle to represent a rectangle. It contains following members: 07 CO2 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. 49. When will you declare a method as a static? Explain static method with suitable example. 07 CO2 50. Explain Java garbage collection mechanism. What is the purpose of the finalize() method. 04 CO2 51. Write a program to create circle class with area function to find area of circle. 07 CO2 52. Discuss various access modifiers available in JAVA? How access modifier affects the 07 CO2 visibility of a member in different access locations? (Winter-19, Summer-21, Winter-22 ) 53. Justify: 07 CO1, 1. Why we declare main() method as public and static member. (Summer-20) CO2 2. Why we generally declare constructor as public member. 3. Why there is no destructor in java. 54. Explain static keyword in detail using a sample program. (Winter-19, Summer-20) 04 CO2 55. Consider class A as the parent of class B. Explain among the following which statement 04 CO2 will show the compilation error. i) A a = new A(); ii) A a = new B(); iii) B b = new A(); iv) B b = new B(); 56. Explain the following constructors using appropriate example: (Summer-22) 04 CO2 i) Default constructor and Parameterised constructor ii) Shallow copy and Deep copy constructor UNIT- 5 Object oriented thinking: 57. Write a program, which shows an example of function overloading. Also, differentiate 07 CO2 between function overloading and overriding. (Summer-20) or Differentiate between Method overloading and Method overriding. Or Explain Method overloading and Method overriding with example. (Winter-22, Winter-21) 58. Describe the following methods related to String i) replace() ii) compareTo() 03 CO2 59. How can we protect sub class to override the method of super class? Explain with CO2 example. (Summer-20) 60. Write a single program which demonstrates the usage of following keywords: 04 CO1, i) import, ii) new, iii) this, iv) break, v) continue CO2 Show how to compile and run the program in java. (Summer-22) 61. Write a program to take string input as command line argument. In addition, count 07 CO2 occurrence of each character in a given string (Summer-20). 62. Define types of polymorphism. 03 CO2 63. Explain Primitive data type and wrapper class data types. (Winter-20) 04 CO2 64. What is wrapper class? What is Autoboxing? OR What is Wrapper class in Java? 3/7 CO2 Explain with examples. 65. Describe the following methods related to String i) replace() ii) compareTo() 07 CO2 66. State whether any error exists in the following code. If so, correct the error and give 07 CO2 output. 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);}} 67. State the design hints for class and inheritance. Also discuss the working and meaning of 07 CO2 the “static” modifier with suitable examples. (Summer-21) 68. What do you mean by run time polymorphism? Write a program to demonstrate run time 07 CO2 polymorphism. (Summer-20) 69. Explain in detail how inheritance and polymorphism are supported in java with necessary 07 CO2 examples. (Summer-21) 70. Write a java program to implement the multiple inheritance concepts for calculating area 07 CO2 of circle and square. (Summer-21) 71. What is Polymorphism? What is Dynamic binding? Show with an example how dynamic 03 CO2 binding works. (Summer-21, Winter-21) 72. Explain following with example: (Winter-21, Winter-22) 07 CO2, i) Finalize() ii) static iii) super iv) final CO3 73. Declare a class called book having author_name as private data member. Extend book 07 CO2 class to have two sub 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. 74. Write a JAVA program to create a super class called figure that stores the dimensions of 07 CO2 a two- dimensional object. It also defines a method called area () that computes the area of an object. The program derives two subclasses 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. 75. Explain different Visibility modifiers. (Winter-21) 03 CO2 76. What is wrapper class? What is the use of wrapper class in Java? 03 CO2 77. How package can be created in JAVA? Explain with suitable example.(Winter-22) 04 CO2 78. Write difference between String class, StringBuilder and StringBuffer class. Also, write a 07 CO2 program to count the occurrence of a character in a string. (Summer-20, Summer-21, Winter-21, Winter-22) 79. What is the Explain difference about differentbetween types ofthe StringBuffer string and. (Summer-21) methods. (Summer-21) 03 CO2 classes? 80. List out different methods available for String class in java and explain any two with 04 CO2 proper example. (Winter-22) UNIT- 6 Exception Handling, I/O, abstract classes and interfaces 81. Differentiate between final, finally and finalize. What will happen if we make class and 07 CO2, method as final? (Winter-20) CO3 82. Define Interface and explain how it differs from the class with suitable example. (Summer- 04 CO2 20, Winter-21) 83. Describe abstract class called Shape, which has three subclasses say Triangle, 07 CO2 Rectangle, and Circle. Define one method area() in the abstract class and override this area() in these three subclasses to calculate for specific object i.e. area() of Triangle subclass should calculate area of triangle likewise for Rectangle and Circle. (Summer-20) 84. Write an abstract class named Person and its two subclasses named Student and 07 CO2 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. 85. Write a program that counts the number of words in a text file. The file name is passed as a 07 CO2 command line argument. The words in the file are separated by white space characters. 86. (Winter-21) What is an Exception? Explain try, catch and finally with example. (Winter-21) 07 CO3 87. Write a program to rise and handle divide by zero exception. (Winter-20) 07 CO3 88. Create a class called Student. Write a student manager program to manipulate the student 07 CO4 information from files by using FileInputStream. (Winter-22) 89. and FileOutputStream. Write a program that illustrates interface inheritance. Interface P is extended by P1 and P2. 07 CO2 Interface P12 inherits from both P1 and P2. Each interface declares one constant and one method. class Q implements P12. Instantiate Q and invoke each of its methods. Each method displays one of the constants. (Winter-21) 90. What is Exception? Demonstrate how you can handle different types of exception 04 CO3 separately. (Winter-20, Winter-22) 91. Explain abstract class with example. (Winter-20, Winter-21) 03 CO2 92. Explain File class with its methods. (Winter-21) 07 CO4 93. Explain file I/O using character stream with appropriate example. (Summer-22) 07 CO4 hint: use FileReader, FileWriter 94. What is an Exception? List out various built-in exceptions in JAVA and explain any one 07 CO3 Exception class with suitable example. (Summer-20) 95. Explain following Java keywords using appropriate examples: (Winter-21, Summer-22) 03 CO3 i) throw, ii) throws, iii) finally 96. What is an Exception? Explain the exception hierarchy. Explain how to throw, catch and 07 CO3 handle Exceptions. (Summer-21) 97. Explain about Final class, Fields, Methods. (Summer-21, Winter-22) 03 CO2 98. Discuss BufferedInputStream and BufferedOutputStream classes with an example. 07 CO4 (Winter-22) 99. Write a method for computing xy doing repetitive multiplication. X and y are of type 07 CO3 integer and are to be given as command line arguments. Raise and handle exception(s) for invalid values of x and y. (Winter-20) 100. Write short notes about I/O stream classes. (Summer-21) 04 CO4 101. Explain the interface with an example program. (Summer-21) 04 CO2 102. Explain about Proxy class, Interface and Methods. (Summer-21) 03 CO2 103. Differentiate between Abstract class and Interfaces. (Summer-22) 03 CO2 104. Explain usage of class FileInputStream and FileOutputStream by giving an example. 04 CO4 (Winter-20, Summer-22) 105. Explain Comparable and Cloneable interface. (Winter-20) 07 CO3 106. Demonstrate use of try-catch construct in case of hierarchical Exception Handling. (i.e 07 CO3 handling various exception belongs to the exception hierarchy) (Summer-22) 107. Discuss exception and error. 02 CO3 108. Write an application that generates custom exception if any value from its command line 07 CO3 arguments is negative. 109. ,Write Dec-13) a method for computing by doing repetitive multiplication. x and y are of type 07 CO3 integer and 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. 110. Write an application that searches through its command-line argument. If an argument is 07 CO3 found that does not begin with and uppercase letter, display error message and terminate. 111. Which class gives you access to the attribute of a file? 01 CO4 112. Write a program to display the bytes of a file in reverse sequence. Provide the 07 CO4 name of the file as a command line argument. (Use RandomAccessFile). 113. Write a program to replace all ―word1‖ by ―word2‖ to a file without using temporary 07 CO4 file and display the no. of replacement. 114. Write a Java program to copy content of file1.txt to file2.txt using Java file handling. 07 CO4 115. Create a class called Student. Write a student manager program to manipulate the 07 CO4 student information from files by using the BufferedReader and BufferedWriter 116. What is a Package? What are the benefits of using packages? Write down the 07 CO2 steps in creating a package and using it in a java program with an example. (Summr-21) 117. Consider following code fragment: 04 CO3 try { statement 1; statement 2; statement 3; } catch (Exception1 ex1) { } finally { statement 4; } statement5; 1. Which Statements will execute if no exception is occurs. 2. Which Statements will execute if Exception 1 is occurs at statement 118. Differentiate the followings: (Summer-20, Summer-19) 07 CO2, 1. Checked and Unchecked Exceptions CO3, 2. Socket and ServerSocket CO4 3. Text I/O and Binary I/O 4. String and StringBuffer 119. What are interfaces in java? How do they support polymorphism? 04 CO2 UNIT- 7 JAVAFX basics and Event-driven programming and animations 120. Explain in brief: Color class and its methods. (Summer-20) 03 CO5 121. Explain the architecture of JavaFX. (Winter-22) 04 CO5 122. Write a short note on JAVAFX controls. (Summer-22, Winter-22) 07 CO5 123. Explain different layout panes used in JavaFX. (Summer-20, Winter-21, Winter-22) 07 CO5 124. Write importance of JAVAFX compare to AWT and Swing. (Summer-20) 04 CO5 125. How do you create a Scene object? How do you set a scene in a stage? Is it possible to 07 CO5 create multiple scenes? Write a program to place a circle. (Summer-20) in the is 126. What scene and filland reflection circle howwith doesred color.to manipulate java code. (Summer-21) it help 04 CO5 127. Explain about callback. (Summer-21) 03 CO5 128. Explain the concept of inner classes and explain the types of inner classes with an 07 CO5 example program. (Summer-21, Winter-21) 129. Explain following classes in JavaFX. (Winter-20) 03 CO5 1) Color class 2) font class 3) Image and image view class 130. Develop a GUI based application using JAVAFX controls. (Summer-22) 07 CO5 131. Explain mouse and key event handler in JavaFX. (Winter-20) 03 CO5 132. Demonstrate animation effect in JavaFX. (Winter-22) 04 CO5 133. What interface defines (i) binding property (ii) source object. (Summer-21) 04 CO5 134. What is a unidirectional binding and what is bidirectional binding? Write a statement 03 CO5 to bind property d1 with property d2 bidirectionally 135. What are the binding object types for int, long, float, double, and boolean? 03 CO5 136. What is a pane? What is a node? How do you place a node in a pane? 03 CO5 137. Write code fragments to display a polygon connecting the following points: (20, 40), 07 CO5 (30, 50), (40, 90), (90, 10), (10, 30), and fill the polygon with green colour. 138. Write a program that draws two circles with radius 15 pixels, cantered at 07 CO5 random locations, with a line connecting the two circles. 139. What is a lambda expression? What is the benefit of using lambda expressions for 03 CO5 event handling? What is the syntax of a lambda expression? 140. What is a functional interface? Why is a functional interface required for a lambda 03 CO5 expression? 141. What methods do you use to register a handler for a mouse pressed, released, clicked, 03 CO5 entered, exited, moved and dragged event? 142. Explain: MouseEvent, KeyEvent, ActionEvent 03 CO5 143. What is an event source object? What is an event object? Describe the relationship 04 CO5 between an event source object and an event object 144. What methods used to register handlers for key pressed, key released, and key typed 07 CO5 events? In which classes are these methods defined? 145. Explain Label and Button class and their methods in detail. 07 CO5 UNIT- 8 JAVAFX UI controls and multimedia 146. Explain following controls: (Winter-20, Winter-21) 07 CO5 1) text-Area 2) scrollbar 3) checkbox 4) combo-box 5) Radio Button (6) Textfield (7) Label 147. (Create a miles/kilometers converter) Write a program that converts miles and 07 CO5 kilometers, as shown in Figure 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 fieldand press the Enter key, the corresponding miles is displayed in the Mile text field. UNIT- 9 Binary I/O, Recursion and Generics 148. How do you declare a generic type in a class? Explain. (Summer-20) 03 CO4 149. Differentiate Text I/O and Binary I/O. (Winter-20, Winter-21) 03 CO4 150. Write a JAVA program to read student.txt file and display the content. (Summer-20) 04 CO4 151. What is Generic programming and why is it needed? Explain with example. List the 07 CO4 limitations and restrictions of generic programming. (Summer-21) 152. Write a program to read the content of a file into a character array and write it into 07 CO4 another file. Get names of the files from command line. 153. Write a program to create a file named example.dat if it does not exist. Append new data 07 CO4 to it if it already exists. Write 100 integers created randomly into the file using binary I/O. 154. How to define Generic class and interface explain with example. 03 CO4 155. Explain wildcard Generic type with example. 07 CO4 UNIT- 10 List, Stacks, Queues and Priority Queues 156. What method do you use to obtain an element in the collection from an iterator? Explain 04 CO4 with example. (Summer-20) 157. What is Vector class? (Winter-22) 03 CO4 158. Write a program to add input elements in ArrayList collection class, then sort the inserted 07 CO4 elements in descending order and display the sorted output. (Summer-22) hint: use 159. Write Collections.reverseOrder() a short note on Java Collections. Also discuss List and Enumeration Interface. 07 CO4 (Summer-22, Winter-22) 160. Write a program to add input elements in ArrayList collection class, then sort the inserted 07 CO4 elements in descending order and display the sorted output. (Summer-22) hint: use Collections.reverseOrder() 161. What is Collection? Explain list, stack, queue classes. (Winter-20) 03 CO4 162. Compare List and Set. (Winter-21) 03 CO4 163. Explain utility class ArrayList and Hashtable with example (Summer-20) 07 CO4 164. List the interfaces, abstract classes and concrete classes of collection hierarchy. 07 CO4 165. Write a complete program to implement a singly linked list with nodes storing integer 07 CO4 information using suitable utility class. 166. Explain use of Linked List collection class with example. 07 CO4 167. What do you understand by Collection framework in java? List methods available in 07 CO4 iterator interface and explain it. (Winter-22) UNIT- 11Sets and Maps 168. Compare Set and List interfaces. (Summer-20) 03 CO4 169. Explain Set and Map in Java with example. (Winter-22) 07 CO4 170. Explain the unique features of Map interface. 03 CO4 171. What are the differences between HashSet, LinkedHashSet, and TreeSet. 07 CO4 172. Describe and compare HashMap, LinkedHashMap, and TreeMap. 07 CO4 173. Write a program that counts the occurrences of words in a text and displays the words 07 CO4 and their occurrences in alphabetical order of the words. [hint: a TreeMap to store an entry consisting of a word and its count] UNIT- 12 Concurrency 174. What is Thread? Explain Thread life cycle in detail. Write a program to create a child 07 CO3 thread to print integer numbers 1 to 10. (Summer-20, Summer-22, Winter-21, Winter- 22) 175. Explain the thread state, thread properties and thread synchronization with example. 07 CO3 (Summer-21, Winter-21, Winter-22) 176. Explain multithreading using Runnable interface. (Summer-22) 04 CO3 177. In multi-threads using the Runnable interface, explain with an example how a start() 04 CO3 method calls the run() method of a class implementing a runnable interface. (Summer-22) 178. What do you understand by thread? Describe the complete life cycle of thread. (Winter- 07 CO3 20 179. Explain multi threading in java using example. (Summer-22) 07 CO3 180. Explain use of following methods with suitable example isAlive(), join(), setPriority(). 07 CO3 181. Differentiate multithreading and multiprocessing. 03 CO3 182. What is the effect of adding the synchronized keyword to a method? 01 CO3 183. Discuss the role of thread synchronization in inter-thread communication? Explain with 07 CO3 example. 184. Explain wait, notify, synchronized and native methods. 05 CO3 185. Write a program of writing binary file using multithreading. Demonstrate use of join() 07 CO3 and yield(), interrupt(). 186. Write a complete multi-threaded program to meet following requirements for producer- 07 CO3 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.