java-mcqs - Set (2)

Correct Answer: Orange && Worng Answer: Red

1. Which of the following variable declaration would not compiled in a java program

  • (A). int var
  • (B). float var
  • (C). double var
  • (D). int-I-var
  • View Answer

    Explanation: The syntax of variable in java is < datatype variablename; >

    2. A constructor is related with

  • (A). Same name as the class it is declared within
  • (B). Is used to create package
  • (C). Is used to define Applet constructor
  • (D). All of above
  • View Answer

    Explanation: Constructors are the member functions which are called automatically whenever an object is created. It is a mandatory functions to be called for an object to be created as this helps in initializing the object to a legal initial value for the class.

    3. JVM is a

  • (A). Java virtual machine
  • (B). Java variable modifier
  • (C). Java vertical machine
  • (D). Java vendor machine
  • View Answer

    Explanation: JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.

    4. What is byte code in context of Java

  • (A). The type of code generated by Java compiler
  • (B). Code generated by Java virtual machine
  • (C). Another name of Java source file
  • (D). Related with Java comments
  • View Answer

    Explanation: Java use compiler and interpreter both where compiler translate java code into byte code and interpreter translate byte code into binray code.

    5. The Java run time system automatically calls this method while garbage collection

  • (A). finalizer ()
  • (B). finalize ()
  • (C). finally ()
  • (D). fanalised ()
  • View Answer

    Explanation: ‘finalize()’ method is automatically called by the java compiler before destroying the object to free any resources.

    6. An overloaded method consist of

  • (A). with same method but different types of parameters
  • (B). with different method name only
  • (C). method name may be same or different
  • (D). all of above
  • View Answer

    Explanation: Overloading method to declear multiple function with same name but use different number of argument.

    7. A protected member can be accessed in

  • (A). Subclass of same package
  • (B). Non sub-class of same package
  • (C). Non sub-class of different package
  • (D). True for both (A) and (B)
  • View Answer

    Explanation: Protected data member and method are only accessible by the classes of the same package and the subclasses present in any package.

    8. All exception types are sub classes of the built in class in

  • (A). Exception
  • (B). Run time exception
  • (C). Error
  • (D). Throwable
  • View Answer

    Explanation: All Exception types are subclasses of the built-in class Throwable. Exception is used for exceptional conditions that user program should catch.

    9. In Java , objects are passed as

  • (A). Copy of that object
  • (B). Method call by value
  • (C). Memory address
  • (D). Constructor
  • View Answer

    Explanation: Objects are passed by call by reference refers to passing the real reference of the variable in memory.

    10. Which of following not a component of Java IDE

  • (A). Net Beans
  • (B). Borland’s Jbuilder
  • (C). Microsoft J++
  • (D). Symantec visual cafe
  • View Answer

    Explanation: An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development.

    11. Which of following is incorrect var-name

  • (A). xyz
  • (B). 2nd name
  • (C). xy2z
  • (D). xyz2
  • View Answer

    Explanation: Variable name always starts with letters.

    12. Applet cann’t be viewed using

  • (A). Netscape navigator
  • (B). Internet Explorer
  • (C). Sun Hot Java Browser
  • (D). Applet viewer tool which comes with JDK
  • View Answer

    Explanation: Not Avilable

    13. Java compiler Javac translate Java source code into

  • (A). Assembly language
  • (B). Byte code
  • (C). Bit code
  • (D). Machine code
  • View Answer

    Explanation: The Java compiler (javac) converts the source code into bytecode.

    14. In Java character const value is its integer value in the

  • (A). EBCDIC char set
  • (B). Unicode char code
  • (C). ASCII char code
  • (D). Binary code
  • View Answer

    Explanation: Not Avilable

    15. Which one of the used to document the program and improve its readability

  • (A). System calls
  • (B). Keyword
  • (C). Comments
  • (D). Blocks
  • View Answer

    Explanation: A comment is a programmer-readable explanation in a program’s code, script, or another file that is not meant to be seen by the user running the program.