Assessment Of Java Training

50 Questions | Total Attempts: 414

SettingsSettingsSettings
Please wait...
Java Quizzes & Trivia

Questions and Answers
  • 1. 
    Which is the valid declarations within an interface definition?
    • A. 

      Public double methoda();

    • B. 

      Public final double methoda();

    • C. 

      Static void methoda(double d1)

    • D. 

      All

  • 2. 
    Which is right way to creating an array of integer in java?
    • A. 

      Int javaArray = new int[10];

    • B. 

      Int avaArray new = myArray[ ];

    • C. 

      Int[] javaArray = new int[10];

    • D. 

      None

  • 3. 
    Which keyword is used to inherit class?
    • A. 

      Inherit

    • B. 

      Extends

    • C. 

      Inheritance

    • D. 

      Extend

  • 4. 
    Which of the java classes that cannot be subclassed?
    • A. 

      Abstract class

    • B. 

      Public class

    • C. 

      Final class

    • D. 

      None of above

  • 5. 
    Can we declare abstract static method?
    • A. 

      Yes

    • B. 

      No

  • 6. 
    Which type of inheritance is not supported by java?
    • A. 

      Single

    • B. 

      Multiple

    • C. 

      Multilevel

    • D. 

      Hirarchical

  • 7. 
    Given interface declaration interface Base  {     boolean m1 ();     byte m2(short s); } which code fragment will compile?
    • A. 

      Interface Base2 implements Base {}

    • B. 

      Abstract class Class2 extends Base { public boolean m1() { return true; } }

    • C. 

      Class Class2 implements Base {}

    • D. 

      Abstract class Class2 implements Base { public boolean m1() { return (7 > 4); } }

  • 8. 
    Java final methods cannot be overridden but overloaded?
    • A. 

      True

    • B. 

      False

  • 9. 
    An abstract class should have methods all declared abstract?
    • A. 

      Yes

    • B. 

      No

  • 10. 
     The finalize() method present in Object class is called just prior to
    • A. 

      An object, variable or method goes out of scope.

    • B. 

      An object or variable goes out of scope.

    • C. 

      A variable goes out of scope

    • D. 

      Before garbage collection

  • 11. 
    Given the below class definitions   class Base { void display () { System.out.println("Base"); } } class Derived extends Base { void display () { System.out.println("Derived"); } } and objects Base b = new Base(); Derived d = new Derived(); Base bd = new Derived(); then the print statements System.out.print(b.display() + " "); System.out.print(d.display() + " "); System.out.print(bd.display() + " "); System.out.println(); will display:
    • A. 

      Base Base Derived

    • B. 

      Base Derived Derived

    • C. 

      Base Derived Base

    • D. 

      Derived Derived Derived

  • 12. 
    Which of the following are primitive types?
    • A. 

      Byte

    • B. 

      String

    • C. 

      Integer

    • D. 

      Float

  • 13. 
    Which of the following statements accurately describe the use of access modifiers(private,public,protected) within a class definition?
    • A. 

      They can be applied to both data & methods

    • B. 

      They must precede a class's data variables or methods

    • C. 

      They can follow a class's data variables or methods

    • D. 

      They can appear in any order

    • E. 

      They must be applied to data variables first and then to methods

  • 14. 
    Which of the following statements correctly describes the relation between an object and the instance variable it stores?
    • A. 

      Each new object has its own distinctive set of instance variables

    • B. 

      Each object has a copy of the instance variables of its class

    • C. 

      The instance variable of each object are seperate from the variables of other objects

    • D. 

      The instance variables of each object are stored together with the variables of other objects

  • 15. 
    The finally block is executed when an exception is thrown, even if no catch matches it.
    • A. 

      Yes

    • B. 

      No

  • 16. 
    Class Test { public static void main(String[] args){   Object obj;   obj.toString(); } }
    • A. 

      NullPointerException

    • B. 

      It will print String representation

    • C. 

      Neither a and b

    • D. 

      ClasscastException

  • 17. 
    Which of the following are the new type in Java
    • A. 

      Class

    • B. 

      Interface

    • C. 

      Both Class and Interface

    • D. 

      Neither a and b

  • 18. 
    Is Floating point operations is supported in MCHAI JVM(CISCO)
    • A. 

      Yes

    • B. 

      No

  • 19. 
    What is the size of int in java 
    • A. 

      2 bytes

    • B. 

      4 bytes

    • C. 

      6 bytes

    • D. 

      Depends on platform

  • 20. 
    Is multiple Inheritance is supported in case of Interfaces?
    • A. 

      Yes

    • B. 

      No

  • 21. 
    Which of the following is true about class defination in a file 
    • A. 

      In a single file any number of class can be defined

    • B. 

      There can be only one public class in a single java file

    • C. 

      Name of public file and class name should match

    • D. 

      All of above

  • 22. 
    Which of the following is wrapper classes in java
    • A. 

      Integer

    • B. 

      Float

    • C. 

      String

    • D. 

      Byte

  • 23. 
    What is the output of following code int x[]={1,2,3,4}; Sytem.out.println(" Index at 4 is "+x[4]);
    • A. 

      IndexOutOfBoundException

    • B. 

      4

    • C. 

      NullPointerException

    • D. 

      3

  • 24. 
    What is the base class of all Java classes?
    • A. 

      Object

    • B. 

      Throwable

    • C. 

      String

    • D. 

      None

  • 25. 
    Given the below code. What is the result?    class Test    {        public static void main(String args[]) {                 String str = "null";                 if (str == null) {                         System.out.print("1");                 } else if (str.length() == 0) {                         System.out.print("2");                 } else {                         System.out.print("3");                 }         }   }
    • A. 

      Compilation fails.

    • B. 

      "1" is printed

    • C. 

      2" is printed.

    • D. 

      "3" is printed.

Back to Top Back to top