Menu
Topics Index
...
`

Session n Test has these questions


Calculate sum

What will be the output of the following program?
public class FindSum
{
    public static void main(String[] args)
    {
        int[] a = {12, 15, 11, 13, 9, 25};
        int[] a2 = {12, 15, 11, 13, 9, 25};
        int sum = 0;
        for (int i = 0; i < a.length; i++)
        {
            if (a[i] % 3 == a2[a.length - i] % 5)
            {
                sum += i * i;
            }
        }
        System.out.println("sum = " + sum);
    }
}
A. sum = 5
B. sum = 25
C. sum = 30
D. Compilation Error
E. Throws ArrayIndexOutOfBoundsException



Size of the name Sachin Tendulkar

How many bytes do we need to store the name 'Sachin Tendulkar' using the char data type?
A. 32
B. 16
C. 15
D. 30



Classes898

What will be the output of the following program?
class OutPut
{
    public static void main(String s[])
    {
        int i = 2;
        B b = new B();
        b.execute();
    }
}

class A
{
    A()
    {
        int i = 1;
    }
}

class B extends A
{
    void execute()
    {
        System.out.println("i = " + i);
    }
}
A. i = 2
B. i = 1
C. Compilation Error
D. Runtime Error



Identify lines of code executed475

What lines of the following program gets executed, given that the exception is thrown at LINE A and at LINE E.
try
{
    // LINE A
    try
    {
        // LINE B
    }
    catch(Exception ex)
    {
        // LINE C
    }
    // LINE D
}
catch(Exception e)
{
    // LINE E
    // LINE F
}
// LINE G
A. A, E
B. A, B, D, E, G
C. A, E, G
D. A, B, D, E, G



Who invented conceived Java

Who invented (conceived) Java?
A. Kerningham
B. James Gosling
C. Steve Jobs
D. Bill Joy



© meritcampus 2019

All Rights Reserved.

Open In App