1. What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.abs(x);
System.out.print(y);
}
}
a) 0
b) 3
c) 3.0
d) 3.1
Explanation:
Output:
3
2. What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.floor(x);
System.out.print(y);
}
}
a) 0
b) 3
c) 3.0
d) 4
Explanation: double floor(double X) returns a largest whole number less than or equal to variable X. Here the smallest whole number less than 3.14 is 3.
3. Which of these methods of Character wrapper can be used to obtain the char value contained in Character object.
a) get()
b) getVhar()
c) charValue()
d) getCharacter()
Explanation: To obtain the char value contained in a Character object, we use charValue() method.
4. Which of the following constant are defined in Character wrapper?
a) MAX_RADIX
b) MAX_VALUE
c) TYPE
d) All of the mentioned
Explanation: Character wrapper defines 5 constants – MAX_RADIX, MIN_RADIX, MAX_VALUE, MIN_VALUE & TYPE.
5. Which of these is a super class of Character wrapper?
a) Long
b) Digits
c) Float
d) Number
Explanation: Number is an abstract class containing subclasses Double, Float, Byte, Short, Character, Integer and Long.
6. Which of these methods is used to know whether a given Character object is part of Java’s Identifiers?
a) isIdentifier()
b) isJavaIdentifier()
c) isJavaIdentifierPart()
d) none of the mentioned
Explanation: isJavaIdentifierPart()
7. Which of these coding techniques is used by method isDefined()?
a) Latin
b) ASCII
c) ANSI
d) UNICODE
Explanation: isDefined() returns true if ch is defined by Unicode. Otherwise, it returns false.
8. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
int a = Character.MAX_VALUE;
System.out.print((char)a);
}
}
a) <
b) >
c) ?
d) $
Explanation: Character.MAX_VALUE returns the largest character value, which is of character ‘?’.
9. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
int a = Character.MIN_VALUE;
System.out.print((char)a);
}
}
a) <
b) !
c) @
d) Space
Explanation: Character.MIN_VALUE returns the smallest character value, which is of space character ‘ ‘.
10.What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
char a = '@';
boolean x = Character.isLetter(a);
System.out.print(x);
}
}
a) true
b) false
c) @
d) B
Explanation:
Output:
false