Krishna School of Emerging Technology and Applied Research
Subject: Programming in Java
Semester: IV
MCQ FOR SECOND MID SEM EXAM
1. Which of these methods of class String is used to extract a single character from a String object?
a) CHARAT()
b) chatat()
c) charAt()
d) ChatAt()
2. The class at the top of the exception classes hierarchy is called
a) Throwable
b) Catchable
c) Hierarchical
d) ArrayIndexOutofBounds
3. Which of these classes is used to read characters in a file?
a) FileReader
b)FileWriter
c)FileInputStream
d) InputStreamReader
5. Which of these classes contains the methods used to write in a file?
a) FileStream
b) FileInputStream
c) BufferedOutputStream
d) FileBufferStream
6. Which of these instance cannot be created?
a) Integer instance
b) Generic class instance
c) Generic type instance
d) Collection instances
7. What is multithreaded programming?
a) It’s a process in which two different processes run simultaneously
b) It’s a process in which two or more parts of same process run simultaneously
c) It’s a process in which many different process are able to access same information
d) It’s a process in which a single process can access information from many sources
8. Which of these statements is incorrect?
a) By multithreading CPU idle time is minimized, and we can take maximum use of it
b) By multitasking CPU idle time is minimized, and we can take maximum use of it
c) Two thread in Java can have the same priority
d) A thread can exist only in two states, running and blocked
9. Which of these method of Thread class is used to find out the priority given to a thread?
a) get()
b) ThreadPriority()
c) getPriority()
d) getThreadPriority()
10. What requires less resources?
a) Thread
b) Process
c) Thread and Process
d) Neither Thread nor Process
11. Which of the following will ensure the thread will be in running state?
a) yield()
b) notify()
c) wait()
d) Thread.killThread()
12. When does Exceptions in Java arises in code sequence?
a) Run Time
b) Compilation Time
c) Can Occur Any Time
d) None of the mentione
13. What will be the output of the following Java program?
class exception_handling
{
public static void main(String args[])
{
try
{
System.out.print("Hello" + " " + 1 / 0);
}
catch(ArithmeticException e)
{
System.out.print("World");
}
}
}
a) Hello
b) World
c) HelloWorld
d) Hello World
14. What will be the output of the following Java program?
class exception_handling
{
public static void main(String args[])
{
try
{
int a, b;
b = 0;
a = 5 / b;
System.out.print("A");
}
catch(ArithmeticException e)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
}
}
a) A
b) B
c) AC
d) BC
15. Which of the following exception must be either caught or declared to be thrown in Java?
a) NullPointerException
b) ArrayIndexOutOfBoundsException
c) FileNotFoundException
d) ArithmeticException
16. Which keyword will you use to specify that a method can potentially throw an exception?
a) try
b) catch
c) throw
d) throws
17. Which of these are types of multitasking?
a) Process based
b) Thread based
c) Process and Thread based
d) None of the mentioned
18. Which of these statements is incorrect?
a) By multithreading CPU idle time is minimized, and we can take maximum use of it
b) By multitasking CPU idle time is minimized, and we can take maximum use of it
c) Two thread in Java can have the same priority
d) A thread can exist only in two states, running and blocked
19. Which of these keywords are used to implement synchronization?
a) synchronize
b) syn
c) synch
d) synchronized
20. Which of this method is used to avoid polling in Java?
a) wait()
b) notify()
c) notifyAll()
d) all of the mentioned
21. Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same
monitor?
a) wait()
b) notify()
c) notifyAll()
d) sleep()
22. Which of these method wakes up all the threads?
a) wakeAll()
b) notify()
c) start()
d) notifyAll()
23. What is synchronization in reference to a thread?
a) It’s a process of handling situations when two or more threads need access to a shared resource
b) It’s a process by which many thread are able to access same shared resource simultaneously
c) It’s a process by which a method is able to access many different threads simultaneously
d) It’s a method that allow too many threads to access any information they require
24. Which of these method is used to implement Runnable interface?
a) stop()
b) run()
c) runThread()
d) stopThread()
25. Which of these methods is used to begin the execution of a thread?
a) run()
b) start()
c) runThread()
d) startThread()
26. Thread priority in Java is?
a) Integer
b) Float
c) double
d) long
27. What will be the output of the following Java code?
class newthread implements Runnable
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
public void run()
{
System.out.println(t.getName());
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
a) My Thread
b) Thread[My Thread,5,main]
c) Compilation Error
d) Runtime Error
28. Which is the feauture of JavaFX?
(a) FXML
(b) Scene Builder
(c) CSS-like Styling
(d) All of them
29. Scene graph contains the following component.
(a) UI Controls
(b) Stage
(c) Prism
(d) None of these
30. GWT provides service to manage
(a) rendering Graphics
(b) Web engine
(c) Windows, timers or surface
(d) Media engine
31. Which method will called by launch() of Application class in JavaFX?
(a) start()
(b) run()
(c) load()
(d) scene()
32. Which is the default argument of start() of Application class in JavaFX?
(a) Node
(b) Stage
(c) Scene
(d) Group
33. Which method is used to add scene to stage?
(a) addScene()
(b) setScene()
(c) showScene()
(d) loadScene()
34. The _____ layout arranges all the nodes in our application in a single horizontal row.
(a) VBox
(b) FlowPane
(c) HBox
(d) TilePane
35. The _____ layout arranges all the nodes in our application in a single vertical column.
(a) VBox
(b) FlowPane
(c) HBox
(d) TilePane
36. In event capturing phase, event travels to all nodes in top to bottom manner.
(a) Target Selection
(b) Route Construction
(c) Event Capturing Phase
(d) Event Bubbling Phase
37. _____ is used to display a short text or an image, it is a non-editable text control.
(a) TextField
(b) Label
(c) TextArea
(d) EditTextView
38. Which of them is correct Label class constructor?
(a) Label()
(b) Label(String text)
(c) Label(String text, Node graphics)
(d) All of them
39. _____ enables an application to have some action executed when the application user clicks the button.
(a) Button
(b) CheckBox
(c) RadioButton
(d) Slider
40. When a button is clicked, the following event is sent.
(a) ButtonEvent
(b) ActionEvent
(c) MouseEvent
(d) ClickEvent
41. _____ is used to provide more than one choices to the user.
(a) ComboBox
(b) TextField
(c) CheckBox
(d) RadioButton
42. Which of the following control is used to implement multiple choice questions?
(a) List
(b) ComboBox
(c) RadioButton
(d) CheckBox
43. _____ allows a user to enter a single line of unformatted text.
(a) TextArea
(b) EditTextView
(c) Label
(d) TextField
44. The following method is used to get text from textfield.
(a) getText()
(b) text()
(c) enteredText()
(d) textEntered()
45. Which of the following is a part of the Java Collections Framework?
a) ArrayList
b) Array
c) int[]
d) String
46. Which is the root interface of the Java Collection framework hierarchy?
a) Collection
b) Root
c) Collections
d) List/Set
47. Which collection does not allow duplicate elements?
a) List
b) Set
c) Map
d) All of the above
48. Which collection allows you to retrieve elements in the order they were inserted?
a) HashSet
b) TreeMap
c) LinkedHashMap
d) PriorityQueue
49. What is the implementation of the List interface?
a. HashMap
b. HashSet
c. LinkedList
d. LinkedHashSet
50. Which collection ensures that elements are processed in first-in-first-out (FIFO) order?
a) HashSet
b) LinkedHashSet
c) LinkedList
d) PriorityQueue