Type Here to Get Search Results !

Java MCQs ( Multiple Choice Questions ) with Answers - Set II

0

 Java MCQ's  with Answers

set II


Q1. Which of the following is true about Java.

a) Java does not support overloading.

b) Java has replaced the destructor function of C++

c) There are no header files in Java.

d) All of the above.

Answer is d) All of the above.
Explanation :
For explanation Join the discussion below

 

Q2. Which of the following is not the Java primitive type

a) Byte

b) Float

c) Character

d) Long double

Answer is d) Long double
Explanation :
For explanation Join the discussion below

 

Q3. The command javac

a) Converts a java program into binary code

b) Converts a java program into bytecode

c) Converts a java program into machine language

d) None of the above.

Answer is b) Converts a java program into bytecode
Explanation :
For explanation Join the discussion below

 

Q4. How many times does the following code segment execute

int x=1, y=10, z=1;
do{y–; x++; y-=2; y=z; z++} while ( y>1 && z<10 )

a) 1

b) 10

c) 5

d) infinite

Answer is a) 1
Explanation :
For explanation Join the discussion below

 

Q5. Inner classes are

a) anonymous classes

b) nested classes

c) subclasses

d) derived classes

Answer is b) nested classes
Explanation :
For explanation Join the discussion below

 

Q6. Java Servlet
i) is a key component of server-side Java development
ii) is a small pluggable extension to a server that enhances functionality
iii) runs only in Windows Operating System
iv) allows developers to customize any java enabled server

a) i, ii & iii are true

b) i, iii & iv are true

c) ii, iii & iv are true

d) i, ii & iv are true

Answer is d) i, ii & iv are true
Explanation :
For explanation Join the discussion below

 

Q7. Command to execute compiled java program is

a) java

b) javac

c) run

d) javarun

Answer is a) java
Explanation :
For explanation Join the discussion below

 

Q8. State whether the following statement is true or false for EJB.
1. EJB exists in the middle-tier
2. EJB specifies an execution environment
3. EJB supports transaction processing

a) 1-true, 2. true, 3. true

b) 1- true, 2. false, 3. true

c) 1- false, 2- false, 3- false

d) 1-true, 2-true, 3-false

Answer is a) 1-true, 2. true, 3. true
Explanation :
For explanation Join the discussion below

 

Q9. ________ are not machine instructions and therefore, Java interpreter generates machine code that can be directly executed by the machine that is running the Java program.

a) Compiled Instructions

b) Compiled code

c) byte code

d) Java mid code

Answer is c) byte code
Explanation :
For explanation Join the discussion below

 

Q10. The JDBC-ODBC bridge allows _______ to be used as _______.

a) ODBC drivers, JDBC drivers

b) Drivers, Application

c) Application, drivers

d) JDBC drivers, ODBC drivers

Answer is a) ODBC drivers, JDBC drivers
Explanation :
For explanation Join the discussion below

 

Q11. What will be the output of the following program?

public class CodingHumans {  
      public static void main(String[] args) {  
         MyFirst obj = new MyFirst(n);  
 }  
 static int a = 10;  
 static int n;  
 int b = 5;  
 int c;  
 public CodingHumans(int m) {  
       System.out.println(a + ", " + b + ", " + c + ", " + n + ", " + m);  
  }  
      // Instance Block  
  {  
     b = 30;  
     n = 20;  
  }   
      // Static Block  
  static   
  {  
          a = 60;  
   }   
 }  

a) 10, 5, 0, 20, 0

b) 10, 30, 20

c) 60, 30, 0, 20, 0

d) 60, 5, 0, 20

Answer is c) 60, 30, 0, 20, 0
Explanation :
For explanation Join the discussion below

 

Q12. Which of the following is a valid long literal?

a) ABH8097

b) L990023

c) 904423

d) 0xnf029L

Answer is d) 0xnf029L
Explanation :
For explanation Join the discussion below

 

Q13.What does the expression float a = 35 / 0 return?

a) 0

b) Not a Number

c) Infinity

d) Run time exception

Ans is c) Infinity
Explanation :
Anything divided by 0 is infinity

 

Q14. Which of the following tool is used to generate API documentation in HTML format from doc comments in source code?

a) javap tool

b) javaw command

c) Javadoc tool

d) javah command

Ans is c) Javadoc tool
Explanation :
For explanation Join the discussion below

 

Q15. Which of the following for loop declaration is not valid?

a) for ( int i = 99; i >= 0; i / 9 )

b) for ( int i = 7; i <= 77; i += 7 )

c) for ( int i = 20; i >= 2; --i )

d) for ( int i = 2; i <= 20; i = 2* i )

Ans is a) for ( int i = 99; i >= 0; i / 9 )
Explanation :
For explanation Join the discussion below

 




Post a Comment

0 Comments

Top Post Ad

Below Post Ad