Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

JAVA QUESTIONS : PART 26

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 ANSWER

What 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 ANSWER

What 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 ANSWER

What 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 ANSWER

What is the order of variables in Enum?

Ascending order

Descending order

Random order

depends on the order() method

SHOW ANSWER

Can we create an instance of Enum outside of Enum itself?

True

False

SHOW ANSWER

If 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 ANSWER

What 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 ANSWER

What 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 ANSWER

Which method returns the elements of Enum class?

getEnums()

getEnumConstants()

getEnumList()

getEnum()

SHOW ANSWER

Which class does all the Enums extend?

 Object

Enums

Enum

EnumClass

SHOW ANSWER

Are 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
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in