Subscribe Us

Core Java - Interview Questions and Answers

331. Which of the following are true about the Error and Exception classes?
a) Both classes extend Throwable.
b) The Error class is final and the Exception class is not.
c) The Exception class is final and the Error is not.
d) Both classes implement Throwable.

Ans : a.

332. Which of the following are true?
a) The Void class extends the Class class.
b) The Float class extends the Double class.
c) The System class extends the Runtime class.
d) The Integer class extends the Number class.

Ans : d.

333. Which of the following will output -4.0
a) System.out.println(Math.floor(-4.7));
b) System.out.println(Math.round(-4.7));
c) System.out.println(Math.ceil(-4.7));
d) System.out.println(Math.Min(-4.7));

Ans : c.

334. Which of the following are valid statements.
a) public class MyCalc extends Math
b) Math.max(s);
c) Math.round(9.99,1);
d) Math.mod(4,10);
e) None of the above.

Ans : e.

335. What is meant by Stream and what are the types of Streams and classes of the Streams?

Ans : A Stream is an abstraction that either produces or consumes information.

There are two types of Streams. They are:
Byte Streams : Byte Streams provide a convenient means for handling input and output of bytes.
Character Streams : Character Streams provide a convenient means for handling input and output of characters.
Byte Stream classes : Byte Streams are defined by using two abstract classes. They are:InputStream and OutputStream.
Character Stream classes : Character Streams are defined by using two abstract classes. They are : Reader and Writer.

336. Which of the following statements are true?
a) UTF characters are all 8-bits.
b) UTF characters are all 16-bits.
c) UTF characters are all 24-bits.
d) Unicode characters are all 16-bits.
e) Bytecode characters are all 16-bits.

Ans : d.

337. Which of the following statements are true?
a) When you construct an instance of File, if you do not use the filenaming semantics of the local machine, the constructor will throw an IOException.
b) When you construct an instance of File, if the corresponding file does not exist on the local file system, one will be created.
c) When an instance of File is garbage collected, the corresponding file on the local file system is deleted.
None of the above.

Ans : a,b and c.

338. The File class contains a method that changes the current working directory.
True/False

Ans : False.

339. It is possible to use the File class to list the contents of the current working directory.
True/False

Ans : a.

340. Readers have methods that can read and return floats and doubles.
True/False

Ans : b.

Post a Comment

0 Comments