GkSeries.com

Data Types in Java - MCQ Questions with Answers - Core Java Quiz

(1) Which of the following is not an valid declaration of an array?
[A] int [ ] a = new int [3];
[B] int a [ ] [ ] = new int [3] [3]
[C] int [ ] [ ] a = new int [3] [ ];
[D] int [ ] [ ] a = new int [ ] [3];

Comment

Answer: Option [D]

In multidimensional array rows cannot left blank.

(2) String.ValueOf('r').concat("def").concat(String.ValueOf('2'))
[A] 0
[B] 1
[C] 3
[D] 4

Comment

Answer: Option [B]

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

(3) Which of the following is correct statement?
[A] Boolean true value is 1 and false value is 0
[B] Every private class has a wrapper class
[C] Constant identifier precede with a reserved word final
[D] System.out.println() method also flushes the buffer

Comment

Answer: Option [C]

Constants are not directly supported by Java. The reserved 'Final' is used to declare constant.

(4) Size of an integer can be
[A] -231 to 231-1
[B] 0 to -216
[C] -28 to 28-1
[D] -215 to 215-1

Comment

Answer: Option [A]

Int takes 4 bytes i.e. 32bits. 1 bit is reserved to store sign.

(5) For which of the following data types the ValueOf() method is NOT overloaded in the string class?
[A] Float
[B] Boolean
[C] Object
[D] None of these

Comment

Answer: Option [D]

For all Java built in types ValueOf() method is overloaded within the String. valueOf() method returns the string representation of the corresponding arguments value.

Please share this page

Chapters

Click Here to Read more questions

Teacher Eligibility Test