Java - Introduction

page 1 out of 2

page 1 out of 2


Question 1     

Which Exception is handled by the below line?

class Test 
{
    public static void main(String args[]) 
    {
        try 
        {
            System.out.print(Integer.parseInt("Hundred");
        }
        catch(Exception e) 
        {
        	System.out.print(e);        	
        }
    }
}





Question 2     

What is the output of the following program?

final class Parent
{
    int i;
}    
class Child extends Parent
{
    int j;
    void display() 
    {
        System.out.println(j + " " + i);
    }
}    
class inheritance 
{
    public static void main(String args[])
    {
        Child obj = new Child();
        obj.i=1;
        obj.j=2;   
        obj.display();     
    }
}







Question 5     

Which is a reserved word in the Java programming language?







Question 6     

Which of the following are legal lines of code?

1) int w = (int)888.8;
2) byte x = (byte)1000L;
3) long y = (byte)100;
4) byte z = (byte)100L;






Question 7     

Which two statements are equivalent?

1) 16*4
2) 16>>2
3) 16/2^2
4) 16>>>2






Question 8     

You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?






Question 9     

Which of the following is/are legal method declarations?

1) protected abstract void m1();
2) static final void m1(){}
3) synchronized public final void m1() {}
4) private native void m1();






Question 10     

What is the output of below code?

    class Array 
    {
        public static void main(String args[]) 
        {
            int array[] = new int [5];
            for (int i = 5; i > 0; i--)
                array[5-i] = i;
            Arrays.fill(array, 1, 4, 8);
            for (int i = 0; i < 5 ; i++)
         System.out.print(array[i]);
        }}




page 1 out of 2

page 1 out of 2


Sign Up Page

Oops!!

To view the solution need to Login



Score : 0 / 0
L
o
a
d
i
n
g
.
.
.