What is the output of this program?
class char_increment
{
public static void main(String args[])
{
char c1 = 'D';
char c2 = 84;
c2++;
c1++;
System.out.println(c1 + " " + c2);
}
}
E U
U E
V E
U F
SHOW ANSWERWhat is the output of this program?
class A
{
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
{
public static void main(String args[])
{
B object = new B();
System.out.print("b is " + b.calculate(0, 1));
}
}
b is : 2
b is : 1
Compilation Error
An exception is thrown at runtime
SHOW ANSWERWhat is the output of this program, if we run as “java main_arguments 1 2 3”?
class Sample
{
public static void main(String [] args)
{
String [][] argument = new String[2][2];
int x;
argument[0] = args;
x = argument[0].length;
for (int y = 0; y < x; y++)
System.out.print(" " + argument[0][y]);
}
}
1 1
1 0
1 0 3
1 2 3
SHOW ANSWERWhat is the output of this program?
class C
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
Hello c
Hello
Hello world
Runtime Error
SHOW ANSWERWhat is the order of variables in Enum?
Ascending order
Descending order
Random order
depends on the order() method
SHOW ANSWERCan we create an instance of Enum outside of Enum itself?
True
False
SHOW ANSWERIf we try to add Enum constants to a TreeSet, what sorting order will it use?
Sorted in the order of declaration of Enums
Sorted in alphabetical order of Enums
Sorted based on order() method
Sorted in descending order of names of Enums
SHOW ANSWERWhat is the output of below code snippet?
class A
{
}
enum Enums extends A
{
ABC, BCD, CDE, DEF;
}
Runtime Error
Compilation Error
It runs successfully
EnumNotDefined Exception
SHOW ANSWERWhat is the output of below code snippet?
enum Levels
{
private TOP,
public MEDIUM,
protected BOTTOM;
}
Runtime Error
EnumNotDefined Exception
It runs successfully
Compilation Error
SHOW ANSWERWhich method returns the elements of Enum class?
getEnums()
getEnumConstants()
getEnumList()
getEnum()
SHOW ANSWERWhich class does all the Enums extend?
Object
Enums
Enum
EnumClass
SHOW ANSWERAre enums are type-safe?
True
False
SHOW ANSWER
Which of these operators is used to allocate memory to array variable in Java?
malloc
alloc
new
new malloc
SHOW ANSWER