Create a Quiz. The academic subject for which the text must be created - Computer science. Content must be appropriate for Year or Grade 11....
What to createQuiz
Which subjectComputer science
What age groupYear or Grade 11
What topicJava - data types, compound assignment, method signature, class, object instantiation
Question typesClose-ended
Number of questions25
Number of answers4
Correct answersExactly 1
Show correct answers
Use images (descriptions)
Any other preferences

Computer Science Quiz: Java Basics for Grade 11

Instructions

Please read each question carefully and choose the correct answer from the options provided.


Questions

  1. What is the default value of a boolean variable in Java?

    • A. true
    • B. false
    • C. null
    • D. 0
  2. Which of the following is NOT a valid data type in Java?

    • A. int
    • B. float
    • C. char
    • D. real
  3. What does a compound assignment operator do in Java?

    • A. Combines multiple variable declarations
    • B. Assigns a value to a variable without changing it
    • C. Allows for operations to be performed and assigned in one statement
    • D. Creates a new variable type
  4. Which of the following is the correct method signature for a method that returns an integer and takes no parameters?

    • A. int method()
    • B. method() int
    • C. int method(void)
    • D. void int method()
  5. What is an object in Java?

    • A. A class itself
    • B. A reference to a variable
    • C. An instance of a class
    • D. A function within a class
  6. Which keyword is used to create a class in Java?

    • A. new
    • B. class
    • C. object
    • D. create
  7. What is the purpose of the 'this' keyword in Java?

    • A. It indicates the end of a method
    • B. It refers to the current object instance
    • C. It creates a new class
    • D. It invokes the superclass constructor
  8. What will be the output of the following code snippet: int a = 5; a += 3;?

    • A. 5
    • B. 8
    • C. 3
    • D. 6
  9. How do you instantiate an object of the class named 'Car'?

    • A. Car myCar = new Car();
    • B. myCar = Car();
    • C. Car myCar();
    • D. new Car myCar;
  10. Which data type can store a single character in Java?

    • A. String
    • B. char
    • C. int
    • D. float
  11. What keyword is used to define a method in a Java class?

    • A. function
    • B. method
    • C. void
    • D. def
  12. *In Java, the compound assignment operator `=` is used for what purpose?**

    • A. Division
    • B. Multiplication and assignment
    • C. Subtraction
    • D. Addition
  13. If a variable is declared as String str;, what is its default value?

    • A. ""
    • B. "null"
    • C. null
    • D. undefined
  14. What does the following method signature indicate: public void displayInfo()?

    • A. It returns an integer and takes no parameters.
    • B. It returns nothing and takes no parameters.
    • C. It takes parameters and returns void.
    • D. It takes no parameters and returns void.
  15. Which of the following statements correctly follows the rules of object-oriented programming?

    • A. Methods can be defined outside of a class.
    • B. Classes can directly access private variables of other classes.
    • C. Objects are created based on classes.
    • D. A class can only contain variables.
  16. What is a class in Java?

    • A. A blueprint for creating objects
    • B. A type of variable
    • C. A built-in data type
    • D. A specific function in programming
  17. Which of the following keywords indicates that a method can be overridden?

    • A. final
    • B. static
    • C. abstract
    • D. public
  18. What will the following code print? System.out.println(10 + 20 + " Hello");

    • A. 30 Hello
    • B. 10 Hello
    • C. Hello 30
    • D. 10 20 Hello
  19. What is the result of int x = 10; x -= 3; in Java?

    • A. 10
    • B. 3
    • C. 7
    • D. 13
  20. What type of variable is declared with the static keyword?

    • A. Instance variable
    • B. Class variable
    • C. Local variable
    • D. Global variable
  21. How can you describe an instance variable?

    • A. It is shared among all objects.
    • B. It belongs to a specific object.
    • C. It cannot be accessed from within the class.
    • D. It is a constant value.
  22. In Java, which data type would you use to represent a decimal number?

    • A. int
    • B. double
    • C. char
    • D. boolean
  23. In the context of Java, what does encapsulation mean?

    • A. Preventing access to certain components of a class
    • B. The use of external libraries
    • C. The process of compiling code
    • D. The identification of errors in code
  24. Which of the following is the correct way to declare an array of integers in Java?

    • A. int[] arr;
    • B. int arr[];
    • C. Both A and B
    • D. Integer arr[10];
  25. What is the return type of a method declared as public int calculate()?

    • A. void
    • B. int
    • C. double
    • D. String

Correct Answers

  1. B
  2. D
  3. C
  4. A
  5. C
  6. B
  7. B
  8. B
  9. A
  10. B
  11. C
  12. B
  13. C
  14. B
  15. C
  16. A
  17. C
  18. A
  19. C
  20. B
  21. B
  22. B
  23. A
  24. C
  25. B