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

9/16

Page

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

Which of these methods of Boolean wrapper returns boolean equivalent of an object.

Select an option to see the answer and solution.

Which of the following is true about Java system properties?

Select an option to see the answer and solution.

Which of these can be used to fully abstract a class from its implementation?

Select an option to see the answer and solution.

Which of the following methods return the value as a double?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.lang.reflect.*;
class Additional_packages
{	 
     public static void main(String args[]) 
     {
   try
         {
       Class c = Class.forName("java.awt.Dimension");
 Field fields[] = c.getFields();
 for (int i = 0; i < fields.length; i++)
     System.out.println(fields[i]);
   }
   catch (Exception e)
         {
               System.out.print("Exception");
         }
    }
}

Select an option to see the answer and solution.

What is the use of Observable class?

Select an option to see the answer and solution.

Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package?

Select an option to see the answer and solution.

Which of the following methods Byte wrapper return the value as a double?

Select an option to see the answer and solution.

Which of these class contains all the methods present in Math class?

Select an option to see the answer and solution.

Which method is used to generate boolean random values in java?

Select an option to see the answer and solution.

What is the length of the application box made in the following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
    Graphic g;
    g.drawString("A Simple Applet",20,20);    
}

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((char)c); 
             }
           }
       }
    }
}

Select an option to see the answer and solution.

What is the value of double consonant 'E' defined in Math class?

Select an option to see the answer and solution.

Which of the following method of Process class can terminate a process?

Select an option to see the answer and solution.

Which of these class is not related to input and output stream in terms of functioning?

Select an option to see the answer and solution.

Which of these class have only one field 'TYPE'?

Select an option to see the answer and solution.

What happens when we access the same variable defined in two interfaces implemented by the same class?

Select an option to see the answer and solution.

Which of these exceptions will be thrown if we declare an array with negative size?

Select an option to see the answer and solution.

What is the Java 8 update of PermGen?

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  = "abcdefgh";
        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, 1, 4);
        int i;
        int j;
        try 
        {
while ((i = input1.read()) == (j = input2.read())) 
            {
                System.out.print((char)i);
            }
        } 
        catch (IOException e) 
        {
      // TODO Auto-generated catch block
            e.printStackTrace();
  }
}
}

Select an option to see the answer and solution.