Java Basics Quiz 2

Java Basics Quiz 2

Time left: 10:00

1. What does JVM stand for?

  • Java Virtual Machine
  • Java Verified Machine
  • Java Variable Machine
  • Java Versatile Machine

2. What is the correct syntax to declare a constant in Java?

  • const int NUMBER = 5;
  • final int NUMBER = 5;
  • static int NUMBER = 5;
  • immutable int NUMBER = 5;

3. Which of the following is used to find and fix bugs in Java programs?

  • JVM
  • JRE
  • JDK
  • JDB

4. What is the output of the following code?
                int a = 10;
                int b = 20;
                int c = a + b;
                System.out.println(c);
            

  • 10
  • 20
  • 30
  • 40

5. Which of the following is not a valid variable name in Java?

  • int1
  • 1int
  • _int
  • int_variable

6. Which of the following is not a reserved keyword in Java?

  • goto
  • const
  • instanceof
  • main

7. What is the correct way to create an object of the class Dog?

  • Dog myDog = new Dog();
  • Dog myDog = Dog();
  • new Dog myDog = new Dog();
  • Dog myDog = Dog.new();

8. What is the output of the following code?
                int[] numbers = {1, 2, 3, 4, 5};
                System.out.println(numbers[3]);
            

  • 1
  • 2
  • 3
  • 4

9. What is the use of the "break" statement in Java?

  • To terminate a loop
  • To skip the current iteration of a loop
  • To return a value from a method
  • To go to the next case in a switch statement

10. What is the default value of a float variable in Java?

  • 0.0
  • 0.0f
  • null
  • 0