What will be the output of the following Java program?
class variable_scope
{
public static void main(String args[])
{
int x;
x = 5;
{
int y = 6;
System.out.print(x + " " + y);
}
System.out.println(x + " " + y);
}
}A. 5 6 5 6
B. 5 6 5
C. Runtime error
D. Compilation error
Select an option to see the answer and solution.
What does LocalTime represent?
A. Date without time
B. Time without Date
C. Date and Time
D. Date and Time with timezone
Select an option to see the answer and solution.
What will be the output of the following Java program?
class mainclass {
public static void main(String args[])
{
char a = 'A';
a++;
System.out.print((int)a);
}
}Select an option to see the answer and solution.
What will be the output of the following Java code snippet?
public class AddDemo
{
public static void main(String args[])
{
BigDecimal b = new BigDecimal("23.43");
BigDecimal br = new BigDecimal("24");
BigDecimal bres = b.add(new BigDecimal("450.23"));
System.out.println("Add: "+bres);
MathContext mc = new MathContext(2, RoundingMode.DOWN);
BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
System.out.println("Add using MathContext: "+bdecMath);
}
}A. Compilation failure
B. Add: 473.66
Add using MathContext: 4.7E+2
C. Add 4.7E+2
Add using MathContext: 473.66
D. Runtime exception
Select an option to see the answer and solution.
What will be the output of the following Java code?
enum Season
{
WINTER, SPRING, SUMMER, FALL
};
System.out.println(Season.WINTER.ordinal());Select an option to see the answer and solution.
Which of these coding types is used for data type characters in Java?
A. ASCII
B. ISO-LATIN-1
C. UNICODE
D. None of the mentioned
Select an option to see the answer and solution.
What is Truncation in Java?
A. Floating-point value assigned to an integer type
B. Integer value assigned to floating type
C. Floating-point value assigned to a Floating type
D. Integer value assigned to an integer type
Select an option to see the answer and solution.
Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?
A. ASCII
B. ISO-LATIN-1
C. None of the mentioned
D. ASCII and ISO-LATIN1
Select an option to see the answer and solution.
How to convert Date object to String?
Options are not available for this question.
Select an option to see the answer and solution.
What will be the output of the following Java program?
class c
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}A. Hello c
B. Hello
C. Hello world
D. Runtime Error
Select an option to see the answer and solution.
How to identify if a timezone is eligible for DayLight Saving?
A. useDaylightTime() of Time class
B. useDaylightTime() of Date class
C. useDaylightTime() of TimeZone class
D. useDaylightTime() of DateTime class
Select an option to see the answer and solution.
Can we create an instance of Enum outside of Enum itself?
Select an option to see the answer and solution.
Which of the following is not provided by BigDecimal?
A. scale manipulation
B. + operator
C. rounding
D. hashing
Select an option to see the answer and solution.
Which of these is necessary condition for automatic type conversion in Java?
A. The destination type is smaller than source type
B. The destination type is larger than source type
C. The destination type can be larger or smaller than source type
D. None of the mentioned
Select an option to see the answer and solution.
What will be the output of the following Java program?
class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i) {
array_variable[i] = i/2;
array_variable[i]++;
System.out.print(array_variable[i] + " ");
i++;
}
}
}A. 0 2 4 6 8
B. 1 2 3 4 5
C. 0 1 2 3 4 5 6 7 8 9
D. 1 2 3 4 5 6 7 8 9 10
Select an option to see the answer and solution.
What will be the output of the following Java code?
class asciicodes {
public static void main(String args[])
{
char var1 = 'A';
char var2 = 'a';
System.out.println((int)var1 + " " + (int)var2);
}
}A. 162
B. 65 97
C. 67 95
D. 66 98
Select an option to see the answer and solution.
What will be the output of the following Java code?
class average {
public static void main(String args[])
{
double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
double result;
result = 0;
for (int i = 0; i < 6; ++i)
result = result + num[i];
System.out.print(result/6);
}
}A. 16.34
B. 16.566666644
C. 16.46666666666667
D. 16.46666666666666
Select an option to see the answer and solution.
What will be the output of the following Java program?
class array_output {
public static void main(String args[])
{
char array_variable [] = new char[10];
for (int i = 0; i < 10; ++i) {
array_variable[i] = 'i';
System.out.print(array_variable[i] + "" );
i++;
}
}
}A. i i i i i
B. 0 1 2 3 4
C. i j k l m
D. None of the mentioned
Select an option to see the answer and solution.
Literals in java must be appended by which of these?
Select an option to see the answer and solution.
Which of these is long data type literal?
A. 0x99fffL
B. ABCDEFG
C. 0x99fffa
D. 99671246
Select an option to see the answer and solution.