Sie sind auf Seite 1von 27

Question 1

Correct
Mark 1.00 out of 1.00

Flag question

Question text

To display text in the applet status bar………method is used.

Select one:
a. showStatusBar()
b. drawStatus()
c. showStatus() 

d. drawStatusBar()
Feedback

The correct answer is: showStatus()

Question 2
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Analyze the following code:

1. public class Test implements Runnable{


2.         public static void main(String[] args){
3.                 Test t = new Test();
4.         }
5.  
6.         public Test(){
7.                 Thread t = new Thread(this);
8.                 t.start();
9.         }
10.  
11.         public void run(){
12.                 System.out.println("test");
13.         }
14. }

Select one:
a. The program compiles fine, but it does not run because you cannot use the keyword
this in the constructor.
b. The program has a compilation error because t is defined in both the main() method
and the constructor Test().
c. The program compiles and runs and displays nothing. 

d. The program compiles and runs and displays test.


Feedback

The correct answer is: The program compiles and runs and displays test.

Question 3
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?

1.     import java.lang.reflect.*;
2.     class Additional_packages {  
3.          public static void main(String args[]) {
4.              try {
5.                  Class c = Class.forName("java.awt.Dimension");
6.                   Method methods[] = c.getMethods();
7.                   for (int i = 0; i < methods.length; i++)
8.                       System.out.println(methods[i]);
9.                   }
10.                  catch (Exception e){
11.                  System.out.print("Exception");
12.                  }
13.             }
14.         }

Select one:
a. Program prints all the constructors of ‘java.awt.Dimension’ package.
b. Program prints all the methods of ‘java.awt.Dimension’ package. 
c. program prints all the methods and data member of ‘java.awt.Dimension’ package.

d. Program prints all the data members of ‘java.awt.Dimension’ package.


Feedback

The correct answer is: Program prints all the methods of ‘java.awt.Dimension’ package.
Question 4
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Which of these operators can skip evaluating right hand operand?

Select one:
a. |
b. &&
c. !

d. & 
Feedback

The correct answer is: &&

Question 5
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Identify the correct full form of JDK ?

Select one:
a. Java Design Kit
b. Java Development Kit 
c. Java Defination Kit

d. Java Data Kit


Feedback

The correct answer is: Java Development Kit

Question 6
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What will happen if you try to compile and run the following code?
public class Q {
            public static void main(String argv[]){
                      int anar[]=new int[5];
                    System.out.println(anar[0]);
           }
}

Select one:
a. 0 
b. null
c. Error: anar is referenced before it is initialized

d. 5
Feedback

The correct answer is: 0

Question 7
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?

1.     class increment {
2.         public static void main(String args[])
3.         {       
4.              int g = 3;
5.              System.out.print(++g * 8);
6.         } 

Select one:
a. 33
b. 32 
c. 25

d. 24
Feedback
The correct answer is: 32

Question 8
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

What is the output of the following code:


class equalS
{
public static void main(String args[])
{
String s1 = “Hello”;
String s2 = new String(s1);
System.out.println(s1==s2);
}
}

Select one:
A. true 
B. 1
C. false

D. Hello
Feedback

The correct answer is: false

Question 9
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Identify the most correct JDK command to run a Java application in ByteCode.class.

Select one:
a. java ByteCode.class
b. javac ByteCode.java 
c. java ByteCode

d. javac ByteCode
Feedback

The correct answer is: java ByteCode

Question 10
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Applet can be embedded in a 

Select one:
a. gif file
b. RTF file
c. html file 

d. MS Word document


Feedback

The correct answer is: html file

Question 11
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


1.      class exception_handling {
2.          publicstaticvoid main(String args[]){
3.              try{
4.                  int a, b;
5.                  b =0;
6.                  a =5/ b;
7.                  System.out.print("A");
8.              }
9.              catch(ArithmeticException e){
10.         System.out.print("B");            
11.            }
12.            finally{
13.                System.out.print("C");
14.            }
15.        }
16.    }

Select one:
a. B
b. A
c. AC

d. BC 
Feedback

The correct answer is: BC

Question 12
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?

1.     class increment {
2.         public static void main(String args[])
3.         {
4.             double var1 = 1 + 5;
5.             double var2 = var1 / 4;
6.             int var3 = 1 + 5;
7.             int var4 = var3 / 4;
8.             System.out.print(var2 + " " + var4);
9.  
10.                  }
11.          }

Select one:
a. 1.5  0
b. 1.5   1 
c. 0  1

d. 1  1
Feedback

The correct answer is: 1.5   1

Question 13
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

To run an applet……….command is used

Select one:
a. run 
b. java
c. appletviewer

d. applet
Feedback

The correct answer is: appletviewer

Question 14
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Which of these package is used for invoking a method remotely?

Select one:
a. java.rmi
b. java.awt
c. java.applet

d. java.util 
Feedback

The correct answer is: java.rmi

Question 15
Correct
Mark 1.00 out of 1.00
Flag question

Question text

The priority of a thread can be got by……method

Select one:
a. getPriority() 
b. prority()
c. setPriority()

d. threadPriority()
Feedback

The correct answer is: getPriority()

Question 16
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of these is an incorrect array declaration?

Select one:
A. int [] arr = new int[5]
B.  int arr[]
arr = new int[5]
C. int arr[] = int [5] new 

D.  int arr[] = new int[5]


Feedback

The correct answer is: int arr[] = int [5] new

Question 17
Correct
Mark 1.00 out of 1.00

Flag question

Question text

In java a thread can be created by ……


Select one:
a. Both Extending the thread class & Implementing Runnable interface 
b. None of the mentioned
c. Extending the thread class

d. Implementing Runnable interface


Feedback

The correct answer is: Both Extending the thread class & Implementing Runnable
interface

Question 18
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Default layout manager for subclasses of "Window" is 

Select one:
a. Frame 
b. GridBagLayout
c. CardLayout

d. BorderLayout
Feedback

The correct answer is: BorderLayout

Question 19
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of these method is used to implement Runnable interface?

Select one:
A. runThread()
B.  stop()
C. run() 
D. stopThread()
Feedback

The correct answer is: run()

Question 20
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Which of these modifiers can be used for a variable so that it can be accessed from any
thread or parts of a program?

Select one:
a. global 
b. transient
c. volatile

d. No modifier is needed


Feedback

The correct answer is: volatile

Question 21
Not answered
Marked out of 1.00

Flag question

Question text

Which method can be used to draw a rectangle in the a Applet?

Select one:
a. drawRect()
b. drawLine()
c. All of the mentioned (drawLine(), drawPolygon() & drawRect() )

d. drawPolygon()
Feedback

The correct answer is: All of the mentioned (drawLine(), drawPolygon() & drawRect() )

Question 22
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of the following operators can operate on a boolean variable?


1.  &&  
2.  ==
3.  =
4.  += 

Select one:
a. 1,2 & 3 
b. 1,2,3 & 4
c. 1 only

d. 1 & 2
Feedback

The correct answer is: 1,2 & 3

Question 23
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What does the AWT stands for ?

Select one:
a. A web toolkit
b. Application with types
c. Abstract Window toolkit 

d. Absolutly wonderfull toolkit


Feedback

The correct answer is: Abstract Window toolkit

Question 24
Incorrect
Mark 0.00 out of 1.00
Flag question

Question text

Identify the most correct valid declarations of a String?

Select one:
a. String s4 = (String) '\ufeed';
b. String s3 = (String) 'abc'; 
c. String s2 = 'null';

d. String s1 = null;
Feedback

The correct answer is: String s1 = null;

Question 25
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

What is the length of the application box made by this program?

1. import java.awt.*;
2.     import java.applet.*;
3.     public class myapplet extends Applet {
4.         public void paint(Graphics g) {
5.             g.drawString("A Simple Applet", 20, 20);   
6.         }
7.     }

Select one:
a. 50
b. 100
c. System dependent 

d. 20
Feedback

The correct answer is: 20

Question 26
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

What will happen after compiling and running following code?

1. class A implements Runnable{


2.       public void run(){
3.             System.out.println("run-a");
4.       }
5. }
6. public class Test{
7.        public static void main(String... args){
8.              A a = new A();
9.              Thread t = new Thread(a);
10.              t.start();
11.              t.start();
12.        }
13.  }

Select one:
a. Compilation fails with an error at line 6
b. Compilation succeed but Runtime Exception
c. run-a

d. run-a run-a 
Feedback

The correct answer is: Compilation succeed but Runtime Exception

Question 27
Not answered
Marked out of 1.00

Flag question

Question text

What is the output of this program ternary_operator?

1.     class ternary_operator {
2.         public static void main(String args[])
3.         {       
4.              int x = 3;
5.              int y = ~ x;
6.              int z;
7.              z = x > y ? x : y;
8.              System.out.print(z);
9.         }
10.      }

Select one:
a. 1
b. 0
c. 3

d. -4
Feedback

The correct answer is: 3

Question 28
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of the following program


class TestApp {
public static void main(String[] args) {
for (int index = 0; 1; index++) {
System.out.println("Welcome");
break;
}
}
}

Select one:
A. Type mismatch error 
B. Run infinite-times
C. Welcome Welcome

D. Welcome
Feedback

The correct answer is: Type mismatch error

Question 29
Not answered
Marked out of 1.00

Flag question

Question text

What is the output of this program?

1. import java.io.*;
2.     class Chararrayinput {
3.         public static void main(String[] args) {
4.             String obj  = "abcdefgh";
5.             int length = obj.length();
6.             char c[] = new char[length];
7.             obj.getChars(0, length, c, 0);
8.             CharArrayReader input1 = new CharArrayReader(c);
9.             CharArrayReader input2 = new CharArrayReader(c, 1,
4);
10.                 int i;
11.                 int j;
12.                 try {
13.                      while((i = input1.read()) == (j = input2.read())) {
14.                         System.out.print((char)i);
15.                     }
16.                 }
17.                 catch (IOException e) {
18.                     e.printStackTrace();
19.                 }
20.             }
21.         }

Select one:
a. abcde
b. None of the mentioned
c. abcd

d. abc
Feedback

The correct answer is: None of the mentioned

Question 30
Correct
Mark 1.00 out of 1.00

Flag question
Question text

The sleep() method can throw an…….exception.

Select one:
a. NullPointerException
b. ThreadException
c. InterruptedExceptoin 

d. IOException
Feedback

The correct answer is: InterruptedExceptoin

Question 31
Not answered
Marked out of 1.00

Flag question

Question text

To set default priority of a thread which constant can be used?

Select one:
a. NORMAL_PRIORITY
b. DEFAULAT_PRIORITY
c. NORM_PRIORITY

d. DEF_PRIORITY
Feedback

The correct answer is: NORM_PRIORITY

Question 32
Not answered
Marked out of 1.00

Flag question

Question text

Java is also known as _________ stage language.

Select one:
a. four
b. two
c. three

d. one
Feedback

The correct answer is: two

Question 33
Not answered
Marked out of 1.00

Flag question

Question text

Which of the following is a method having same name as that of its class?

Select one:
A. class
B. constructor
C.  finalize

D. delete
Feedback

The correct answer is: constructor

Question 34
Not answered
Marked out of 1.00

Flag question

Question text

On invoking repaint() method for a Component, the method invoked by AWT is : 

Select one:
a. update()
b. draw()
c. show()

d. paint()
Feedback

The correct answer is: paint()


Question 35
Not answered
Marked out of 1.00

Flag question

Question text

Which of these statement is correct?

Select one:
A. switch statement is more efficient than a set of nested ifs.
B. switch statement can only test for equality, whereas if statement can evaluate any
type of boolean expression.
C. two case constants in the same switch can have identical values.

D. it is possible to create a nested switch statements.


Feedback

The correct answer is: two case constants in the same switch can have identical values.

Question 36
Not answered
Marked out of 1.00

Flag question

Question text

What is the output of this program?


1. class multithreaded_programing {
2. public static void main(String args[]) {
3. Thread t = Thread.currentThread();
4. System.out.println(t);
5. }
6. }

Select one:
A. Thread[main,5,main]
B. Thread[main,5]
C. Thread[main,0]

D. Thread[5,main]
Feedback
The correct answer is: Thread[main,5,main]

Question 37
Not answered
Marked out of 1.00

Flag question

Question text

Which of the following is not assignment operator?

Select one:
A. =
B. = =
C. +=

D. %=
Feedback

The correct answer is: = =

Question 38
Not answered
Marked out of 1.00

Flag question

Question text

The syntax of drawstring() method is……………..

Select one:
a. void drawstring(String s,int x,int y)
b. void drawstring(String x,int x)
c. void drawstring(String s)

d. void drawstring(int x,int y,string s)


Feedback

The correct answer is: void drawstring(String s,int x,int y)

Question 39
Not answered
Marked out of 1.00

Flag question
Question text

which of the following is an optional attribute of applet tag?

Select one:
a. Width
b. Name
c. Height

d. Code
Feedback

The correct answer is: Name

Question 40
Not answered
Marked out of 1.00

Flag question

Question text

What is the output of the following program:


public class testmeth
{
static int i = 1;
public static void main(String args[])
{
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}
}

Select one:
A. 3 , 1
B. 1 , 3
C. 1 , 0

D. 1 , 1
Feedback
The correct answer is: 1 , 1

Question 41
Not answered
Marked out of 1.00

Flag question

Question text

What will be the output of the following Java program?


abstract class A
{
int i;
abstract void display();
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class Abstract_demo
{
public static void main(String args[])
{
B obj = new B();
obj.j=2;
obj.display();
}
}

Select one:
A. Compilation Error
B. Runtime Error
C. 2

D. 0
Feedback

The correct answer is: 2

Question 42
Not answered
Marked out of 1.00

Flag question

Question text

An expression involving byte, int, and literal numbers is promoted to which of these?

Select one:
A. long
B. float
C.  byte

D.  int
Feedback

The correct answer is:  int

Question 43
Not answered
Marked out of 1.00

Flag question

Question text

Which of these package is used for graphical user interface?

Select one:
a. java.awt.image
b. java.applet
c. java.io

d. java.awt
Feedback

The correct answer is: java.awt

Question 44
Not answered
Marked out of 1.00

Flag question

Question text

What will be the result of compiling the following code?


public class MyClass{
public static void main(String args[]){
System.out.println(“In first main()”);
}
public static void main(char args[]){
System.out.println(‘a’);
}
}
 

Select one:
A. The code will compile correctly but will give a runtime exception
B. The code will compile correctly and will print “In first main()” (without quotes) when it
is run
C. The code will not compile and will give “Duplicate main() method declaration” error

D. The code will compile correctly and will print “In first main()” (without quotes) when it
is run
Feedback

The correct answer is: The code will compile correctly and will print “In first main()”
(without quotes) when it is run

Question 45
Not answered
Marked out of 1.00

Flag question

Question text

What will happen when you compile and run the following code?
public class MyClass{
    static int i;
    public static void main(String argv[]){
            System.out.println(i);
           }
}

Select one:
a. 0
b. null
c. 1
d. Error Variable i may not have been initialized
Feedback

The correct answer is: Error Variable i may not have been initialized

Question 46
Not answered
Marked out of 1.00

Flag question

Question text

_____ is used to find and fix bugs in the Java programs.

Select one:
A. JDK
B. JDB
C. JVM

D. JRE
Feedback

The correct answer is: JDB

Question 47
Not answered
Marked out of 1.00

Flag question

Question text

Identify the most correct valid declaration (Instruction/line of code) of an object of


class Box?

Select one:
a. obj = new Box();
b. Box obj = new Box();
c. new Box obj;

d. Box obj = new Box;


Feedback

The correct answer is: Box obj = new Box();


Question 48
Not answered
Marked out of 1.00

Flag question

Question text

Which of these operators can be used to get run time information about an object?

Select one:
a. Info
b. getinfoof
c. getInfo

d. instanceof
Feedback

The correct answer is: instanceof

Question 49
Not answered
Marked out of 1.00

Flag question

Question text

What is the output of this program?

1. class equality {
2.         int x;
3.         int y;
4.         boolean isequal(){
5.             return(x == y); 
6.         }
7.     }   
8.     class Output {
9.         public static void main(String args[])
10.         {
11.             equality obj = new equality();
12.             obj.x = 5;
13.             obj.y = 5;
14.             System.out.println(obj.isequal());
15.         }
16.     }
Select one:
a. false
b. 1
c. 0

d. true
Feedback

The correct answer is: true

Question 50
Not answered
Marked out of 1.00

Flag question

Question text

The old name of Java was ?

Select one:
a. oak
b. C Language
c. J language

d. oct
Feedback

The correct answer is: oak

Das könnte Ihnen auch gefallen