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

15/16

Page

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

Which of these method can set the out stream to OutputStream?

Select an option to see the answer and solution.

Which of the following constant are defined in Boolean wrapper?

Select an option to see the answer and solution.

Which of these type parameters is used for a generic class to return and accept any type of object?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.util.*;
public class genericstack  
{
    Stack  stk = new Stack ();
public void push(E obj)
    {
        stk.push(obj);
}
public E pop()
    {
        E obj = stk.pop();
  return obj;
}
}
class Output
{
    public static void main(String args[])
    {
        genericstack  gs = new genericstack();
        gs.push("Hello");
        System.out.print(gs.pop() + " ");
        genericstack  gs = new genericstack();
        gs.push(36);
        System.out.println(gs.pop());
    }
}

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.5);  
        boolean x = i.isNaN();
        System.out.print(x);
    }
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the range of numbers returned by Math.random() method?

Select an option to see the answer and solution.

What will be the output of the following Java program?
    package pkg;
    class display 
    {
        int x;
        void show() 
        {
            if (x > 1)
                System.out.print(x + " ");
        }
    }
    class packages 
    {
        public static void main(String args[]) 
        {
            display[] arr=new display[3];
            for(int i=0;i<3;i++)
                arr[i]=new display();
            arr[0].x = 0;      
            arr[1].x = 1;
            arr[2].x = 2;
            for (int i = 0; i < 3; ++i)
                arr[i].show();
         }
    }

Note : packages.class file is in directory pkg;

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.5);  
        Double x = i.MIN_VALUE;
        System.out.print(x);
    }
}

Select an option to see the answer and solution.

Which of these methods loads the specified dynamic library?

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[])
    {
        int a = Character.MIN_VALUE;
        System.out.print((char)a);
    }
}

Select an option to see the answer and solution.

Which of these class can encapsulate an entire executing program?

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[])
     {
         long start, end;   
         start = System.currentTimeMillis();
         for (int i = 0; i < 10000000; i++);
         end = System.currentTimeMillis();
         System.out.print(end - start);
     }
}

Select an option to see the answer and solution.

Which class is used to generate random number?

Select an option to see the answer and solution.

Which of these class can be used to implement the input stream that uses a character array as the source?

Select an option to see the answer and solution.

Which of these is a process of converting a simple data type into a class?

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.14;  
        int y = (int) Math.toDegrees(x);
        System.out.print(y);
    }
}

Select an option to see the answer and solution.

Which of these method(s) is/are used for writing bytes to an outputstream?

Select an option to see the answer and solution.

Which of these exceptions will be thrown if we use null reference for an arithmetic operation?

Select an option to see the answer and solution.

Which of these is a super class of wrappers Long, Character & Integer?

Select an option to see the answer and solution.