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 8

What is the output of this program?

5 6 5 6

5 6 5

Runtime error

Compilation error

SHOW ANSWER

Which of these is an incorrect string literal?

“Hello World”

 “Hello\nWorld”

“\”Hello World\””

”Hello

          World”

SHOW ANSWER

What is the output of this program?
      class dynamic_initialization 
      {
        public static void main(String args[]) 
        {

            double a, b;
                    a = 3.0;
                    b = 4.0;
                double c = Math.sqrt(a * a + b * b);
                System.out.println(c);

            
             }
           }

5.0

25.0

7.0

Compilation Error

SHOW ANSWER

Which of these is necessary condition for automatic type conversion in Java?

The destination type is smaller than source type

The destination type is larger than source type

The destination type can be larger or smaller than source type

None of the mentioned

SHOW ANSWER

If an expression contains double, int, float, long, then the whole expression will be promoted    into which of these data types?

long

 int

double

float

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?
    class c 
    {    
        public void main( String[] args ) 
        {  
            System.out.println( "Hello" + args[0] ); 
        } 
    }
 

Hello c

Hello

Hello world

Runtime Error

SHOW ANSWER

Which of these operators is used to allocate memory to array variable in Java?

malloc

alloc

new

new malloc

SHOW ANSWER

Which of these is an incorrect array declaration?

 int arr[] = new int[5].

int [] arr = new int[5].

 int arr[] = new int[5].

int arr[] = int [5] new

SHOW ANSWER

What will this code print?

0

 value stored in arr[0].

Class name@ hashcode in hexadecimal form

00000

SHOW ANSWER

Which of these is an incorrect Statement?

It is necessary to use new operator to initialize an array

Array can be initialized using comma separated expressions surrounded by curly braces

Array can be initialized when they are declared

None of the mentioned

SHOW ANSWER

Which of these is necessary to specify at time of array initialization?

Row

Column

Both Row and Column

None of the mentioned

SHOW ANSWER

What is the output of this 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;
                System.out.print(array_variable[i] + " ");
                i++;
            }
        } 
    }

 0 2 4 6 8

 1 3 5 7 9

0 1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9 10

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