java multiple choice question

By Team Alpha | Computer | Mar 29, 2018









  1. Which is valid declaration of a float?

    1. float f = 1F;

    2. float f = "1";

    3. float f = 1.0d;

    4. float f = 1.0;





Ans a. (float f = 1F;)


  1. /* Missing Statement ? */



public class too

{

public static void main(String[]args)throws Exception

{

java.io.PrintWriter out = new java.io.PrintWriter();

new java.io.OutputStreamWriter(System.out,true);

out.println("Hello Word");

}

}

Which line of code should replace the missing statement to make this program compile?


  1. port java.io.PrintWriter;

  2. import java.io.*;

  3. include java.io.*;

  4. No statement required.



Ans d.( No statement required.)

 


  1. What is the name of the method used to start  thread execution?

    1. start();

    2. resume();

    3. init();

    4. run();





Ans a. (start();)


  1. Which cannot directly cause a thread to stop executing?

    1. Calling notify() method on an object.

    2. Calling the wait() method on an object.

    3. Calling read() method on an InputStream object.

    4. Calling the SetPriority() method on a Thread object.





Ans a.( Calling notify() method on an object.)


  1. Which of the following will directly stop execution of Thread?

    1. exits synchronized code

    2. notifyall()

    3. wait()

    4. notify()





Ans d. (notify())


  1. What method must be defined by class implementing the java.lang.Runnable interface?

    1. public void run()

    2. void run(int priority)

    3. public void start()

    4. void run()





Ans a.( public void run())


  1. Which method registers a thread in a thread scheduler?

    1. register();

    2. start();

    3. run();

    4. construct();





Ans b. (start();)


  1. Which symbol is used to denote a multi-line comment?

    1. < >

    2. / /

    3. { }

    4. /* */





Ans d.(/* */)


  1. What allows the programmer to destroy an object x?

    1. delete()

    2. Only the garbage collection system can destroy an object.

    3. getRuntime().gc()

    4. finalize()





Ans b. (Only the garbage collection system can destroy an object.)


  1. Which of the following is not a Java keyword?

    1. of

    2. Default

    3. Volatile

    4. For





Ans a.(of)


  1. Which symboolare used to terminates every line of code in Java.

    1. )

    2. }

    3. .

    4. ;





Ans  d.(;)


  1. Which command used to compile Java program in the command prompt.

    1. Jav

    2. Jav

    3. Javac

    4. java





Ans d.(java)


  1. It is the process of removing errors found in the program.

    1. Running

    2. Compiling

    3. Debugging

    4. Editing





Ans c.(Debugging)


  1. _ is a form of Java program that runs locally on the command line.

    1. Applets

    2. Application

    3. Servlets

    4. Midlets





Ans b.(Application)


  1. Which of the following is the data type used for a single character?

    1. Short

    2. Char

    3. Byte

    4. Long





Ans b.(Char)


  1. What do you mean infinite loop?

    1. A loop that functions infinitely well

    2. A loop that will never function

    3. A loop that never starts

    4. A loop that runs forever





Ans d.(A loop that runs forever)


  1. Which symbol is used to denote a multi-line comment?

    1. < >

    2. / /

    3. { }

    4. /* */





Ans b.(//)


  1. Java Compiler:

    1. Produces java Interpreter

    2. Creates classes

    3. Creates executable

    4. It translates java source code to byte code





Ans d.( It translates java source code to byte code)


  1. Order of three top level elements of the java source file are

    1. Package ,Import, Class

    2. Class , Import , Package

    3. Random order

    4. Import , Class , Package





Ans a.( Package ,Import, Class)


  1. Which code is use in java to represent the character?

    1. Unicode

    2. Byte Code

    3. ASCII code

    4. None of the above





Ans a. (Unicode)

 

 

Share this Post

(इस पोस्ट को अपने दोस्तों के साथ शेयर करना ना भूले)

Posts in Other Categories

Get Latest Update(like G.K, Latest Job, Exam Alert, Study Material, Previous year papers etc) on your Email and Whatsapp
×
Subscribe now

for Latest Updates

Articles, Jobs, MCQ and many more!