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

14/16

Page

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

How many bits are used for generating random numbers?

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[])
     {
         char a[] = {'a', '5', 'A', ' '};   
         System.out.print(Character.isDigit(a[0])+ " ");
         System.out.print(Character.isWhitespace(a[3])+ " ");
         System.out.print(Character.isUpperCase(a[2]));
    }
}

Select an option to see the answer and solution.

Which of these methods is called when observed object has changed?

Select an option to see the answer and solution.

Which of these class allows us to get real time data about private and protected member of a class?

Select an option to see the answer and solution.

Which of the following is not a memory classification in java?

Select an option to see the answer and solution.

What will be the output of the following Java program?
public class BoxDemo 
{
    public static <U> void addBox(U u, 
    java.util.List<Box<U>> boxes) 
    {
       Box<U> box = new Box<>();
       box.set(u);
       boxes.add(box);
    }
    public static <U> void outputBoxes(java.util.List<Box<U>> boxes)
    {
        int counter = 0;
        for (Box<U> box: boxes) 
        {
            U boxContents = box.get();
            System.out.println("Box #" + counter + " contains [" + boxContents.toString() + "]");
            counter++;
        }
    }        
    public static void main(String[] args)
    {
        java.util.ArrayList<Box<Integer>> listOfIntegerBoxes = new java.util.ArrayList<>();
        BoxDemo.<Integer>addBox(Integer.valueOf(10), listOfIntegerBoxes);
        BoxDemo.outputBoxes(listOfIntegerBoxes);
    }
}

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

Select an option to see the answer and solution.

Which of these methods of Character wrapper can be used to obtain the char value contained in Character object.

Select an option to see the answer and solution.

Which class loader loads jar files from JDK directory?

Select an option to see the answer and solution.

What will be the output of the following Java code snippet?
int a = random.nextInt(15) + 1;

Select an option to see the answer and solution.

Which of these stream contains the classes which can work on character stream?

Select an option to see the answer and solution.

Which of the following is the correct way of importing an entire package 'pkg'?

Select an option to see the answer and solution.

Why are generics used?

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");
 Method methods[] = c.getMethods();
 for (int i = 0; i < methods.length; i++)
     System.out.println(methods[i]);
   }
   catch (Exception e)
         {
             System.out.print("Exception");
         }
    }
}

Select an option to see the answer and solution.

Which of these is a super class of wrappers Double and Float?

Select an option to see the answer and solution.

Can "abstract" keyword be used with constructor, Initialization Block, Instance Initialization and Static Initialization Block.

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.MAX_VALUE;
        System.out.print((char)a);
    }
}

Select an option to see the answer and solution.

Which of these methods can be used to check whether the given value is a number or not?

Select an option to see the answer and solution.

Which of these method of Locale class can be used to obtain country of operation?

Select an option to see the answer and solution.

What will be the output of the following Java program?
class newthread implements Runnable 
{
Thread t1,t2;
    newthread() 
    {
        t1 = new Thread(this,"Thread_1");
        t2 = new Thread(this,"Thread_2");
        t1.start();
        t2.start();
}
public void run() 
    {
        t2.setPriority(Thread.MAX_PRIORITY);	
  System.out.print(t1.equals(t2));
    }    
}
class multithreaded_programing 
{
    public static void main(String args[]) 
    {
        new newthread();        
    }
}

Select an option to see the answer and solution.