My Report

Java Programming Mock Test 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. A class member declared protected becomes a member of subclass of which type?

Question 1 of 10

Question 2 of 10

2. What will be the output of the following Java program?

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

Question 2 of 10

Question 3 of 10

3. Which of the following is used for implementing inheritance through class?

Question 3 of 10

Question 4 of 10

4. Which of these method of Object class is used to obtain class of an object at run time?

Question 4 of 10

Question 5 of 10

5. What will be the output of the following Java snippet, if compiled and executed with command line "hello there"?

public class abc
{
    String[] xyz;

    public static void main(String argv[])
    {
        xyz=argv;
    }

    public void runMethod()
    {
        System.out.println(argv[1]);
    }
}

Question 5 of 10

Question 6 of 10

6. Which of these data type can be used for a method having a return statement in it?

Question 6 of 10

Question 7 of 10

7. Which class allows parsing of command line arguments?

Question 7 of 10

Question 8 of 10

8. What will be the output of the following Java program?

 
    class recursion 
    {
        int fact(int n) 
        {
            int result;
            if (n == 1)
                return 1;
            result = fact(n - 1) * n;
            return result;
        }
    } 
    class Output 
    {
        public static void main(String args[]) 
        {
            recursion obj = new recursion() ;
            System.out.print(obj.fact(1));
        }
    }

Question 8 of 10

Question 9 of 10

9. Static members are not inherited to subclass.

Question 9 of 10

Question 10 of 10

10. Which of these keywords cannot be used for a class which has been declared final?

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.