21.
What will be the output of the following Java code?
class area 
{
    int width;
    int length;
    int area;
    void area(int width, int length) 
    {
        this.width = width;
        this.length = length;
    }

}    
class Output 
{
    public static void main(String args[])
    {
        area obj = new area();
        obj.area(5 , 6);
        System.out.println(obj.length + " " + obj.width);        
    } 
}

22.
What will be the output of the following Java program?
class main_class 
{
    public static void main(String args[])
    {
        int x = 9;
        if (x == 9) 
        { 
            int x = 8;
            System.out.println(x);
        }
    } 
}

24.
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(6));
    }
}

25.
What will be the output of the following Java program?
class box 
{
    int width;
    int height;
    int length;
} 
class mainclass 
{
    public static void main(String args[]) 
    {        
         box obj = new box();
         obj.width = 10;
         obj.height = 2;
         obj.length = 10;
         int y = obj.width * obj.height * obj.length; 
         System.out.print(y);
    } 
}

27.
Which of the following statements is correct?

28.
Which of this statement is incorrect?

30.
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));
    }
}

Read More Section(Constructors and Methods)

Each Section contains maximum 100 MCQs question on Constructors and Methods. To get more questions visit other sections.