Java Assessment Quiz

15 Questions | Attempts: 1333

SettingsSettingsSettings
Java Assessment Quiz - Quiz

How much do you know about Java? Well, soon, we will find it out when you will take this Java assessment quiz. Java is known as a high-level, class-based, object-oriented programming language. The language is designed to possess as few implementation dependencies as possible. It's one of the most used programming languages out there. We hope you like this quiz and learn more about Java as you take it. All the best, programmer!


Questions and Answers
  • 1. 
    Which is the correct option about the java interface?
    • A. 

      The interface is used to achieve multiple inheritances in Java

    • B. 

      The object of an interface cannot be created.

    • C. 

      An interface can extend another interface.

    • D. 

      All of the above

  • 2. 
    In what memory area do variable temp and variable card write in main () get stored? class CreditCard{ int num; } public class Bank { public static void main(String[] args) { int temp; CreditCard card; } }
    • A. 

      Heap, Heap

    • B. 

      Stack, stack

    • C. 

      Heap, Stack

    • D. 

      Stack, Heap

  • 3. 
    What is the output of this java program? public class MemoryJava { public static void main(String[] args) { decreaseNumberbyOne(2); } public static void decreaseNumberbyOne(int num){ if(num >= 0){ decreaseNumberbyOne(num -1); } System.out.println("Number:"+num); } }
    • A. 

      -1,0,1,2

    • B. 

      2,1,0,-1

    • C. 

      Stack overflow

    • D. 

      No output

  • 4. 
    Which polymorphism behavior do you see in the below class? class Paint { // all methods have same name public void Color(int x) { } public void Color(int x, int y) { } public void Color(int x, int y, int z) { } }
    • A. 

      Method overloading

    • B. 

      Constructor overloading

    • C. 

      Method overriding

    • D. 

      Run time polymorphism

  • 5. 
    __________ can be used to control the order of certain data structures and collection of objects too.
    • A. 

      Serial Comparators

    • B. 

      Natural Comparators

    • C. 

      Comparators

    • D. 

      All of the above

  • 6. 
    In the below java code, whose “Car” will be called? class Father { public void car() { System.out.println("Father's Car"); } } class Son extends Father { public void car() { System.out.println("Son's Car"); } } public class Sample { public static void main(String[] args) { Son john = new Son(); john.car(); } }
    • A. 

      Father’s Car

    • B. 

      Son’s Car

    • C. 

      There is an ambiguity, so no one's Car

    • D. 

      Compiler Error

  • 7. 
    What exception can occur in the below java program if we access 5 element in the array that does not exist? public class TException { public static void main(String[] args) { try { int a[] = { 5, 10, 15, 20 }; System.out.println("Element :" + a[4]); } finally{} } }
    • A. 

      ArrayIndexOutOfBoundsException

    • B. 

      ArithmeticException

    • C. 

      NullPointerException

    • D. 

      None

  • 8. 
    After the following code fragment, what is the value in fname? String str; int fname; str = “Foolish boy.”; fname = str.indexOf(“fool”);
    • A. 

      0

    • B. 

      2

    • C. 

      -1

    • D. 

      4

  • 9. 
    Direct subclass of Throwable in Java
    • A. 

      Exception

    • B. 

      Error

    • C. 

      Both A & C

    • D. 

      None

  • 10. 
    Given the following code snippet; int salaries[]; int index = 0; salaries = new int salaries[4]; while (index < 4) { salaries[index] =  10000; index++; } What is the value of salaries[3]?
    • A. 

      40000

    • B. 

      50000

    • C. 

      15000

    • D. 

      10000

  • 11. 
    Assume that the value 3929.92 is of type float. How to assign this value after declaring the variable interest of type float?
    • A. 

       interest = 3929.92

    • B. 

      Interest = (Float)3929.92

    • C. 

      Interest = 3929.92(float)

    • D. 

      Interest = 3929.92f

  • 12. 
    What is the data type for the number 9.6352?
    • A. 

       float

    • B. 

      Double

    • C. 

      Float

    • D. 

      Double

  • 13. 
    In a class definition, the special method provided to be called to create an instance of that class is known as a/an
    • A. 

      Interpreter 

    • B. 

      Destructor 

    • C. 

      Constructor 

    • D. 

      Object 

    • E. 

      Compiler

  • 14. 
     What is the meaning of the return data type void?
    • A. 

      An empty memory space is returned so that the developers can utilize it.

    • B. 

      Void returns no data type.

    • C. 

      Void is not supported in Java.

    • D. 

       None of the above.

  • 15. 
     Java object oriented programming concepts is/are
    • A. 

      Encapsulation

    • B. 

      Inheritance

    • C. 

      Polymorphism

    • D. 

      All of the above.

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.