Vidyalelo
Java Programming · all questions

Interfaces and Abstract Classes
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

309

Questions

8/16

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following Java program?
package pkg;
class output 
{
    public static void main(String args[])
    { 
        StringBuffer s1 = new StringBuffer("Hello");
        s1.setCharAt(1, x);
        System.out.println(s1);
    }
}

Select an option to see the answer and solution.

Which of these exceptions handles the situations when an illegal argument is used to invoke a method?

Select an option to see the answer and solution.

What will be the output of the following Java program?
class Output 
{
     public static void main(String args[]) 
    {
        double x = 2.0;  
        double y = 3.0;
        double z = Math.pow( x, y );
        System.out.print(z);
    }
}

Select an option to see the answer and solution.

Which of the following constant are defined in Character wrapper?

Select an option to see the answer and solution.

What will happen if we provide concrete implementation of method in interface?

Select an option to see the answer and solution.

Which of these class provides various types of rounding functions?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.lang.System;
class Output 
{
    public static void main(String args[])
    {
        byte a[] = { 65, 66, 67, 68, 69, 70 };
        byte b[] = { 71, 72, 73, 74, 75, 76 };  
        System.arraycopy(a, 0, b, 0, a.length);
        System.out.print(new String(a) + " " + new String(b));
    }
}

Select an option to see the answer and solution.

Which environment variable is used to set java path?

Select an option to see the answer and solution.

Which system property stores installation directory of JRE?

Select an option to see the answer and solution.

Which of these coding techniques is used by method isDefined()?

Select an option to see the answer and solution.

What will be the output of the following Java program?
class Output 
{
     public static void main(String args[]) 
    {
        double x = 3.1;  
        double y = 4.5;
        double z = Math.max( x, y );
        System.out.print(z);
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java code?
class Output
{
    public static void main(String args[])
    {
  Double i = new Double(257.578123456789);  
        float x = i.floatValue();
        System.out.print(x);
    }
}

Select an option to see the answer and solution.

What is the return type of Math.random() method?

Select an option to see the answer and solution.

What is the value of "d" in the following Java code snippet?
double d = Math.round ( 2.5 + Math.random() );

Select an option to see the answer and solution.

Which of these is an correct way of defining generic class?

Select an option to see the answer and solution.

Which of the following is the correct way of implementing an interface A by class B?

Select an option to see the answer and solution.

Where is String Pool stored?

Select an option to see the answer and solution.

What will be the output of the following Java program?
class exception_handling 
{
        static void throwexception() throws ArithmeticException 
        {        
            System.out.print("0");
            throw new ArithmeticException ("Exception");
        }
        public static void main(String args[]) 
        {
        try 
        {
            throwexception();
        }
        catch (ArithmeticException e) 
        {
                System.out.println("A");
        }
    }
}

Select an option to see the answer and solution.

Which of these keywords is used by a class to use an interface defined previously?

Select an option to see the answer and solution.

Classes and Methods are stored in which space?

Select an option to see the answer and solution.