Java MCQ Question and Answer

Java MCQ Question and Answer
11. Which of the following are true about the Error and Exception classes?
  • Both classes extend Throwable.
  • The Error class is final and the Exception class is not.
  • The Exception class is final and the Error is not.
  • Both classes implement Throwable.
Show Answer
12. Which of the following are true?
  • The Void class extends the Class class.
  • The Float class extends the Double class.
  • The System class extends the Runtime class.
  • The Integer class extends the Number class.
Show Answer
13. Which of the following will output -4.0
  • System.out.println(Math.floor(-4.7));
  • System.out.println(Math.round(-4.7));
  • System.out.println(Math.ceil(-4.7));
  • System.out.println(Math.Min(-4.7));
Show Answer
14. Which of the following are valid statements
  • public class MyCalc extends Math
  • Math.max(s);
  • Math.round(9.99,1);
  • None of the above.
Show Answer
15. ) What will happen if you attempt to compile and run the following code? Integer ten=new Integer(10); Long nine=new Long (9); System.out.println(ten + nine); int i=1; System.out.println(i + ten);
  • 19 followed by 20
  • 19 followed by 11
  • Error: Can't convert java lang Integer
  • 10 followed by 1
Show Answer
16. Which of the following statements are true?
  • UTF characters are all 8-bits.
  • UTF characters are all 16-bits.
  • UTF characters are all 24-bits.
  • Unicode characters are all 16-bits.
Show Answer
17. Which of the following statements are true? a)When you construct an instance of File, if you do not use the file naming 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. d)None of the above
  • a&b
  • b,c&d
  • a,c&b
  • b,c&d
Show Answer
18. Which of the following are true? a)The InputStream and OutputStream classes are byte-oriented. b)The ObjectInputStream and ObjectOutputStream do not support serialized object input and output. c)The Reader and Writer classes are character-oriented. d)The Reader and Writer classes are the preferred solution to serialized object output.
  • a&b
  • c&b
  • d&c
  • a&c
Show Answer
19. Which of the following are true about I/O filters? a)Filters are supported on input, but not on output. b)Filters are supported by the InputStream/OutputStream class hierarchy, but not by the Reader/Writer class hierarchy. c)Filters read from one stream and write to another. d)A filter may alter data that is read from one stream and written to another.
  • a&b
  • c&d
  • c&a
  • b&c
Show Answer
20. Which of the following are true? a)Any Unicode character is represented using 16-bits. b)7-bits are needed to represent any ASCII character. c)UTF-8 characters are represented using only 8-bits. d)UTF-16 characters are represented using only 16-bits.
  • a&c
  • b&c
  • a&b
  • d&a
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test