Head First Java - Chapter One Test

14 Questions | Total Attempts: 263

SettingsSettingsSettings
Java Quizzes & Trivia

The test over chapter one.


Questions and Answers
  • 1. 
    What is a statement?
    • A. 

      A single line of code ending in a semicolon

    • B. 

      A block of code that actually does something

    • C. 

      A method required to be created within the class

  • 2. 
    What is the name of the required method in all Java applications?
  • 3. 
    All lines of code begin or end in a curly brace.
    • A. 

      True

    • B. 

      False

  • 4. 
    How do you know what to name the file?
    • A. 

      You name it from the main method

    • B. 

      You name it from the class containing the main method

    • C. 

      You name it from the first statement in the file

  • 5. 
    Name the three types of variables we learned in this chapter: _____, _____, and _____.
  • 6. 
    Java is case-sensitive.
    • A. 

      True

    • B. 

      False

  • 7. 
    Java ignores whitespace.
    • A. 

      True

    • B. 

      False

  • 8. 
    The following is the syntax of a while loop: while (condition) { ... }
    • A. 

      True

    • B. 

      False

  • 9. 
    What is this operator: ==
    • A. 

      Assignment Operator

    • B. 

      Equality Operator

    • C. 

      Loop Operator

  • 10. 
    What is the value of x in the following code snippet? int x = 7; int r = 9; while (x < r) {      x = x + 1; } System.out.print(x);
  • 11. 
    Curly braces are put after which portions of code:
    • A. 

      Classes

    • B. 

      Source File

    • C. 

      Methods

    • D. 

      Statements

  • 12. 
    int x = 1; int num = 1; while(num < 3) {      System.out.print(x + num);      num = num + 1; } The above code would output: 2 3
    • A. 

      True

    • B. 

      False

  • 13. 
    What turns your java file into bytecode for the computer to understand?
  • 14. 
    What do all java files end with (before put into the compiler)? What's the file extension, in other words?
Back to Top Back to top