Subscribe Us

Core Java - Interview Questions and Answers

311. Which of the following is not a wrapper class?

String
Integer
Boolean
Character
Ans : a.

312. What is the output of the following program?

public class Question {
public static void main(String args[]) {
String s1 = "abc";
String s2 = "def";
String s3 = s1.concat(s2.toUpperCase( ) );
System.out.println(s1+s2+s3);
}
}
A) abcdefabcdef
B) abcabcDEFDEF
C) abcdefabcDEF
D) None of the above

ANS : c.

313. Which of the following methods are methods of the String class?
A) delete( )
B) append( )
C) reverse( )
D) replace( )

Ans : d.

314. Which of the following methods cause the String object referenced by s to be changed?
s.concat( )
s.toUpperCase( )
s.replace( )
s.valueOf( )

Ans : a and b.

315. Which of the following are legal operations?
a) s3=s1 + s2;
b) s3=s1 - s2;
c) s3=s1 & s2
d) s3=s1 && s2

Ans : a.

316. Which of the following statements are true?
a) The String class is implemented as a char array, elements are addressed using the stringname[] convention
b) Strings are a primitive type in Java that overloads the + operator for concatenation
c) Strings are a primitive type in Java and the StringBuffer is used as the matching wrapper type
d) The size of a string can be retrieved using the length property.

Ans : b.


EXPLORING JAVA.LANG

317. java.lang package is automatically imported into all programs.
True/False

Ans : True

318. What are the interfaces defined by java.lang?

Ans : Cloneable, Comparable and Runnable.

319. What are the constants defined by both Float and Double classes?

Ans : MAX_VALUE,
MIN_VALUE,
NaN,
POSITIVE_INFINITY,
NEGATIVE_INFINITY and
TYPE.

320. What are the constants defined by Byte, Short, Integer and Long?

Ans : MAX_VALUE,
MIN_VALUE and
TYPE.

Post a Comment

0 Comments