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

13/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?
class X 
{
    int a;
    double b;
}
class Y extends X 
{
int c;
}
class Output 
{
    public static void main(String args[]) 
    {
        X a = new X();
        Y b = new Y();
        Class obj;
        obj = a.getClass();
        System.out.print(obj.getName());
    }
}

Select an option to see the answer and solution.

Which of these is specified by a File object?

Select an option to see the answer and solution.

What will be the output of the following Java code?
class isinfinite_output 
{
    public static void main(String args[]) 
    {
        Double d = new Double(1 / 0.);  
        boolean x = d.isInfinite();
        System.out.print(x);
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
class X 
{
    int a;
    double b;
}
class Y extends X 
{
int c;
}
class Output 
{
    public static void main(String args[]) 
    {
        X a = new X();
        Y b = new Y();
        Class obj;
        obj = b.getClass();
        System.out.print(obj.isLocalClass());
    }
}

Select an option to see the answer and solution.

What happens when a constructor is defined for an interface?

Select an option to see the answer and solution.

Which of the following is an incorrect statement about packages?

Select an option to see the answer and solution.

Which of these data type is returned by every method of OutputStream?

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 i = new Double(257.578123456789);  
        float x = i.floatValue();
        System.out.print(x);
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.io.*;
class Chararrayinput 
{
    public static void main(String[] args) 
    {
  String obj  = "abcdef";
        int length = obj.length();
        char c[] = new char[length];
        obj.getChars(0, length, c, 0);
        CharArrayReader input1 = new CharArrayReader(c);
        CharArrayReader input2 = new CharArrayReader(c, 0, 3);
        int i;
        try 
        {
while ((i = input2.read()) != -1) 
            {
                System.out.print((char)i);
            }
        } 
        catch (IOException e) 
        {
      // TODO Auto-generated catch block
            e.printStackTrace();
  }
}
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.io.*;
public class filesinputoutput 
{
  public static void main(String[] args) 
    {
 String obj  = "abc";
       byte b[] = obj.getBytes();
       ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
       for (int i = 0; i < 2; ++ i) 
       {
           int c;
           while ((c = obj1.read()) != -1) 
           {
             if (i == 0) 
               {
                   System.out.print(Character.toUpperCase((char)c));
                   obj2.write(1); 
             }
           }
           System.out.print(obj2);
       }
    }
}

Select an option to see the answer and solution.

Which of these is a wrapper for data type int?

Select an option to see the answer and solution.

What is the signature of Math.random() method?

Select an option to see the answer and solution.

Which of these class contains only floating point functions?

Select an option to see the answer and solution.

Which of these classes can return more than one character to be returned to input stream?

Select an option to see the answer and solution.

Which of these classes is used for input and output operation when working with bytes?

Select an option to see the answer and solution.

Standard output variable 'out' is defined in which class?

Select an option to see the answer and solution.

Which of these class produce objects with respect to geographical locations?

Select an option to see the answer and solution.

What will be the output of the following Java code?
class binary 
{
     public static void main(String args[]) 
     {
         int num = 17;
         System.out.print(Integer.toBinaryString(num));
     }
}

Select an option to see the answer and solution.

Which of these classes encapsulate runtime state of an object?

Select an option to see the answer and solution.

Which of the following is method of System class is used to find how long a program takes to execute?

Select an option to see the answer and solution.