Java Mcqs
Java Mcqs
488
UNIT 4
1. An instance of are unchecked exceptions
2. An application responds to an exception by throwing an another exception is called as
.
3. Benifits of exception handling
a.Separating Error-Handling code from “regular”
business logic codeb.Propagating errors up the call
stack
c.Grouping and
differentiating error types
d.none
4. A thread can acquire a lock by using which reserved keyword
a. volatile b. synchronized c. locked d. none
10. Which method on a condition should you invoke to wake all waiting thread?
a) condition.wake(); b) condition.signal();
c) condition.wakeAll(); d) condition.signalAll();
14. A thread is a
15.This thread is called the thread because it is the thread that executes when you start the main
program.
A) float B) main C) void D) int
20. Which of these class is related to all the exceptions that cannot be caught?
a) Error
b) Exception
c) RuntimeExecption
d) All of the mentioned
21. Mutual exclusion of shared resource between threads is achieved with _________keyword
488
22. Which of these handles the exception when no catch is used?
a) Default handler
b) finally
c) throw handler
d) Java run time system
24. Which of these class is related to all the exceptions that are explicitly thrown?
a) Error
b) Exception
c) Throwable
d) Throw
25. You can use the __________ method to force one thread to wait for another thread to
Finish
sleep(long milliseconds) b. yield() c. stop() d. join()
25. A thread can acquire a lock by using which reserved keyword
A. volatile B. synchronized C. locked D.
none
26. How many threads can a process contain
A. 1 B.2 C. multiple D. none
27. Two types of streams in java are _______________ and _______________
28. A Java exception is an instance of ____________ _ . [ ]
a. Runtime Exception b. Exception c. Error d. Throw able
29. Program statements that are to be monitored for exceptions are contained within block.[
]
a. try b. catch c. throw d. throws
30. modifier can be accessed only to classes in the same package.
2. Which of these exception is thrown in cases when the file specified for writing it not
found?
a) IOException
b) FileException
c) FileNotFoundException
d) FileInputException
3. Which of these values is returned by read() method is end of file (EOF) is encountered?
a) 0
b) 1
c) -1
d) Null
6. . Which of these packages contain classes and interfaces used for input &
output operationsof a program?
a) java.util
b) java.lang
c) java.io
d) All of the mentioned
9. Which of these class is not related to input and output stream in terms of functioning?
a) File
b) Writer
c) InputStream
d) Reader
11. Which of these is method for testing whether the specified element is a file or a
directory?
a) IsFile()
b) isFile()
c) Isfile()
d) isfile()
14. Which of these is a method to clear all the data present in output buffers?
a) clear()
b) flush()
c) fflush()
d) close()
.
15. Which of these is method is used for writing bytes to an outputstream?
a) put()
b) print()
488
c) printf()
d) write()
488
16. Which of these method of FileReader class is used to read characters from a file?
a) read()
b) scanf()
c) get()
d) getInteger()
17. Which of these class can be used to implement input stream that uses a character array as
the source?
a) BufferedReader
b) FileReader
c) CharArrayReader
d) FileArrayReader
18.Which of these is a method to clear all the data present in output buffers?
a) clear()
b) flush()
c) fflush()
d) close()
19. Non recoverable exceptions belongs to the class
a. Error b. Exception
c. IllegalException d. ClassNotFoundException
20 Which of these classes can return more than one character to be returned to input stream?
a) BufferedReader
b) Bufferedwriter
c) PushbachReader
d) CharArrayReader
21. Which of these class is used to read and write bytes in a file
a.. FileReader b. FileWriter c.FileInputStream d.RandomAccessFile
22. In jdbc network protocol driver ______________interface is used to connect to database