Sail E0 Webinar

MCQs

Total Questions : 158 | Page 1 of 16 pages
Question 1.


What is the output of this program?


import java.util.*;
class LOCALE_CLASS {
public static void main(String args[]) {
Locale obj = new Locale("HINDI", "INDIA") ;
System.out.print(obj.getDisplayLanguage());
}
}
  1.    India
  2.    INDIA
  3.    HINDI
  4.    Nothing is displayed
 Discuss Question
Answer: Option C. -> HINDI

None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI


Question 2.


What is the output of this program?


import java.util.*;
class LOCALE_CLASS {
public static void main(String args[]) {
Locale obj = new Locale("HINDI", "INDIA") ;
System.out.print(obj.getDisplayLanguage());
}
}
  1.    India
  2.    INDIA
  3.    HINDI
  4.    Nothing is displayed
 Discuss Question
Answer: Option C. -> HINDI

None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI


Question 3.

Which of these constant value will change when the button at the end of 

scroll bar was clicked to increase its value?


  1.    BLOCK_DECREMENT
  2.    BLOCK_INCREMENT
  3.    UNIT_DECREMENT
  4.    UNIT_INCREMENT
 Discuss Question
Answer: Option D. -> UNIT_INCREMENT

UNIT_INCREMENT VALUE will change when the button at the end of scroll bar 

Question 4.

Which of these is superclass of ContainerEvent class?


  1.    WindowEvent
  2.    ComponentEvent
  3.    ItemEvent
  4.    InputEvent
 Discuss Question
Answer: Option B. -> ComponentEvent

ContainerEvent is superclass of ContainerEvent, FocusEvent, KeyEvent, 

MouseEvent and WindowEvent.


Question 5.


What is the output of this program?


class string_class {
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = "hello";
System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
}
}
  1.    false false
  2.    true true
  3.    true false
  4.    false true
 Discuss Question
Answer: Option D. -> false true

equals() is method of class String, it is used to check equality of two String objects, if they 

are equal, true is retuned else false.
output:
$ javac string_class.java
$ java string_class
false true


Question 6.

Which of these is superclass of WindowEvent class?


  1.    WindowEvent
  2.    ComponentEvent
  3.    ItemEvent
  4.    InputEvent
 Discuss Question
Answer: Option B. -> ComponentEvent

ContainerEvent is superclass of ContainerEvent, FocusEvent, KeyEvent, MouseEvent 

and WindowEvent.


Question 7.


What is the output of this program?


class newthread implements Runnable {
Thread t;
newthread() {
t = new Thread(this,"My Thread");
t.start();
}
public void run() {
System.out.println(t);
}
}
class multithreaded_programing {
public static void main(String args[]) {
new newthread();
}
}
  1.    My Thread
  2.    Thread[My Thread,5,main]
  3.    Compilation Error
  4.    Runtime Error
 Discuss Question
Answer: Option B. -> Thread[My Thread,5,main]

None.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
Thread[My Thread,5,main]


Question 8.


What is the output of this program?


class A {
int i;
int j;
A() {
i = 1;
j = 2;
}
}
class Output {
public static void main(String args[])
{
A obj1 = new A();
System.out.print(obj1.toString());
}
}
  1.    true
  2.    false
  3.    String associated with obj1
  4.    Compilation Error
 Discuss Question
Answer: Option C. -> String associated with obj1

toString() is method of class Object, since it is superclass of every class, every object has this 

method. toString() returns the string associated with the calling object.
output:
$ javac Output.java
$ java Output
A@1cd2e5f


Question 9.


What value will this program return to Java run-time system?


import java.lang.System;
class Output {
public static void main(String args[]) {
System.exit(5);
}
}
  1.    0
  2.    1
  3.    4
  4.    5
 Discuss Question
Answer: Option D. -> 5

None.

Question 10.


Will this program generate same output is executed again?


class Output {
public static void main(String args[]) {
int y = double z = Math.random();
System.out.print(y);
}
}
  1.    Yes
  2.    No
  3.    Compiler Dependent
  4.    Operating System Dependent
 Discuss Question
Answer: Option B. -> No

There is no relation between random numbers generated previously in Java.


Latest Videos

Latest Test Papers