Object Oriented Programming with Java
ToledoSlackGitHub Org 1GitHub Org 2
Primary version
Primary version
  • About this Course
  • Introduction to Computer Programming
    • Introduction to Computer Programming
    • Challenges
    • Multiple Choice
  • Basic Building Blocks
    • Basic Building Blocks
    • Challenges
    • Multiple Choice
  • Starting in Java
    • Starting in Java
    • Challenges
    • Multiple Choice
  • Storing and Processing Data
    • Storing and Processing Data
    • Challenges
    • Multiple Choice
  • Making Decisions
    • Making Decisions
    • Challenges
    • Test Yourself
    • Multiple Choice
  • Loop Constructs
    • Loop Constructs
    • Challenges
    • Multiple Choice
  • Strings
    • Strings
    • Challenges
    • Multiple Choice
  • Arrays
    • Arrays
    • Challenges
    • Multiple Choice
  • Object Oriented Thinking
    • Object Oriented Thinking
  • All About Objects
    • All About Objects
    • Multiple Choice
  • Defining Classes
    • Defining Classes
    • Challenges
    • Multiple Choice
  • Methods
    • Methods
    • Challenges
    • Multiple Choice
  • Constructors
    • Constructors
    • Multiple Choice
  • Inheritance
    • Inheritance
  • Starting with JavaFX
    • Starting with JavaFX
  • Hands On
    • Hands on MQTT
    • Hands on GSON
  • Hack @ IT
    • Hack @ IT
    • Caesar Encryption
      • Solution
    • Complex Numbers
  • Assignments
    • Number Characteristics
    • Linear Equation
    • LineSegment
  • Videos
    • Videos
  • Sources
    • Sources
Powered by GitBook
On this page
  1. Making Decisions

Multiple Choice

  1. How do we call the number >= 15 part in the if statement below?

     if (number >= 15) {
       System.out.println("Sorry, number is too large");
     }
  2. When you wish to check if an integral number differs from another integral number, then you need to use the ... operator.

  3. How many if else clauses can we add to an if statement?

  4. What is the output of the following code snippet?

     boolean x = false;
     boolean y = true;
     int z = 13;
    
     if (z > 10 || (x != true && y == false)) {
       System.out.println("Sorry, access denied");
     } else {
       System.out.println("Nice one, access granted");
     }
  5. What is the value of a that will be printed to the terminal?

     int a = 15;
     if (true || (a > 100)) {
         a = a + 2;
     }
     System.out.println("a = " + a);
  6. Which of the operators below is a comparison operator?

  7. What is the resulting value in E?

     boolean A = true;
     boolean B = false;
     boolean C = true;
     boolean D = (A && B ) || C;
     boolean E = (!D) || (!A);
  8. What condition is required (in place of <condition_here>) to get a list of all even numbers between 0 (inclusive) and 100 (exclusive)?

     System.out.print("All even numbers between 0 and 100: ");
     for (int i = 0; i < 100; i++) {
         if (<condition_here>) {
             System.out.print(i + " ");
         }
     }
PreviousTest YourselfNextLoop Constructs

Last updated 5 years ago