Java MCQ'S
Java MCQ'S
}
enum Enums extends A
{
ABC, BCD, CDE, DEF;
}
public MEDIUM,
protected BOTTOM;
}
ion contains double, int, float, long, then the whole expression will be promoted into which of these data types?
class conversion
{
public static void main(String args[])
{
double a = 295.04;
int b = 300;
byte c = (byte) a;
What willbytebed the
= (byte) b; of the following Java code?
output
class A System.out.println(c + " " + d);
{ }
} final public int calculate(int a, int b) { return 1; }
}
class B extends A
{
public int calculate(int a, int b) { return 2; }
}
public class output
{
Whatpublic static
will be the void main(String
output args[]) Java program, if we run as “java
of the following
{
main_arguments 1 2 3”?
B object = new B();
class main_arguments
{ System.out.print("b is " + b.calculate(0, 1));
}public static void main(String [] args)
} {
String [][] argument = new String[2][2];
int x;
argument[0] = args;
Which xof=these is an incorrect array declaration?
argument[0].length;
for (int y = 0; y < x; y++)
System.out.print(" " + argument[0][y]);
Which } of these is an incorrect Statement?
}
class Output
{
Whatpublic
will bestatic
the void main(String
output args[]) Java code snippet?
of the following
{
import double x = 3.14;
java.util.*;
class Arraylists Math.ceil(x);
int y = (int)
{ System.out.print(y);
}
public static void main(String args[])
} {
ArrayLists obj = new ArrayLists();
obj.add("A");
obj.add("B");
obj.add("C");
obj.add(1, "D");
System.out.println(obj);
}
}
What will be the output of the following Java code?
0 1 2
0.00999999999999999
0.01 0.01
0.01
0.00999999999999999 0.01
1 0
useDaylightTime() of Time class useDaylightTime() of Date classuseDaylightTime() of TimeZone class
java.sql.Date java.util.Date java.sql.DateTime
Date diffInMilli =
long diffInMilli = long diffInMilli =
java.time.Duration.between(d
java.time.Duration.between java.time.difference(dateTime1, ateTime1,
(dateTime1, dateTime2).toMillis(); dateTime2).toMillis();
dateTime2).toMillis();
38 39 40
EU UE VE
38 43 39 44 295 300
b is : 2 b is : 1 Compilation Error
1 1 1 0 1 0 3
int arr[] = new int[5] int [] arr = new int[5] int arr[] = new int[5]
It is necessary to use new operator to Array can be initialized using Array can be initialized when
comma separated expressions
initialize an array they are declared
surrounded by curly braces
3 0 4
boolean b4 = ‘true’ C
Depends on the order() method D
B
3 A
EnumNotDefined Exception B
Compilation Error D
getEnum() B
Precision D
Bigdecimal D
0.009999999999999998
A
0.009999999999999998
DateConverter A
SimpleDateFormat sdf = new
SimpleDateFormat("yyyy-mm-dd"); B
new Date().format();
B
useDaylightTime() of DateTime class C
java.util.DateTime A
Time diffInMilli =
java.time.Duration.between(dateTime1, A
dateTime2).toMillis();
41 C
1 2 3 4 5 6 7 8 9 10 B
Compilation error D
UF A
B Type casting a larger variable into a smaller
variable results in modulo of larger variable by
range of smaller variable. b contains 300 which
is larger than byte’s range i:e -128 to 127
295.04 300 hence d contains 300 modulo 256 i:e 44.
class Output
{ 257 256
public static void main(String args[])
{
Integer
What will i = new
be the Integer(257);
output of the following Java program?
byte x = i.byteValue();
System.out.print(x);
final class A
{ }
} int i; 22 33
}
class B extends A
{
int j; ServerRea
System.out.println(j + " " + i); Server
der
}
Which class provides system independent server side implementation?
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.display();
}
}
Option C Option D Answer Explanation
65 64 A
1 0 C
1 0 D
67 95 66 98 B
None of the
0 A
mentioned