Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

4/18/2018 Java Foundations - Teacher - English

Test: Section 5 Quiz
Answer the question(s) on this page, and click Next to go to the next test page. Click Summary to see which questions you need to answer
before submitting the test. Click Finish Test if you are ready to submit your test.
Section 5 Quiz
(Answer all questions in this section)
1. How should Strings be compared?  Mark for Review 
(1) Points  
~=
The equals() method
=
==

2. A String comparison with == compares the Strings’ locations in memory and not the content of the String.  Mark for Review 
(1) Points  
True
False

3. The equal sign (=) is used to make an assignment, whereas the == sign merely makes a comparison and  Mark for Review 
returns a boolean.  
(1) Points
True
False

4. An if/else statement is used when you need to choose between two alternatives.  Mark for Review 
(1) Points  
True
False

5. What is the output?  Mark for Review 
   
public static void main(String[] args) {
(1) Points  
   int age = 43;  
 
   if (age == 43){
 
     System.out.print("Bob is 43 ");
   }  
 
   if (age == 50){
 
     System.out.print("Bob is 50 "); 
   }
}  
No output
Bob is 43 Bob is 50
Bob is 43
Bob is 50

Page 1 of 3 Next Summary Finish Test

http://ilearning.oracle.com/ilearn/en/learner/jsp/player.jsp?rco_id=2005667757&classroom_id=2035474607&scorm_attempt=1524034423157&sessionId=-192216619015240344
4/18/2018 Java Foundations - Teacher - English
Test: Section 5 Quiz
Answer the question(s) on this page, and click Next to go to the next test page. Click Summary to see which questions you need to answer
before submitting the test. Click Finish Test if you are ready to submit your test.
Section 5 Quiz
(Answer all questions in this section)
6. What are the possible values of a boolean data type in Java?  Mark for Review 
(1) Points  
true/false
good/bad
yes/no
0/1

7. Which three are conditional statements?  Mark for Review 
(1) Points  
(Choose all correct answers)
do while loop
for loop
if statement
switch statement
if/else statement

8. Which two are not logical operators?  Mark for Review 
(1) Points  
(Choose all correct answers)
||
%
&&
+
!

9. An employee is eligible for a bonus based on certain criteria.  Mark for Review 
Under what conditions does “Eligible for a bonus” print?  
    (1) Points  
int rating; 
int experience;
 
if (rating > 1 && experience == 5) {
 
   System.out.println (“Eligible for a bonus”);
}  

5 experience and 2 or more rating
Less than 5 experience and 1 rating.
5 experience and 1 rating
5 rating and 1 experience

10. In a boolean expression which uses the && operator, what would make this expression evaluate to true?  Mark for Review 
   
boolean x = (firstCondition && secondCondition);
(1) Points  
If both the first condition and second condition are true
If the first condition is false, but the second condition is true
If both the first condition and second condition are false
If the first condition is true, but the second condition is false

Previous Page 2 of 3 Next Summary Finish Test

http://ilearning.oracle.com/ilearn/en/learner/jsp/player.jsp?rco_id=2005667757&classroom_id=2035474607&scorm_attempt=1524034423157&sessionId=-192216619015240344
4/18/2018 Java Foundations - Teacher - English
Test: Section 5 Quiz
Answer the question(s) on this page, and click Next to go to the next test page. Click Summary to see which questions you need to answer
before submitting the test. Click Finish Test if you are ready to submit your test.
Section 5 Quiz
(Answer all questions in this section)
11. In Java, an if statement can be nested inside another if statement.  Mark for Review 
(1) Points  
True
False

12. The switch statement is a more efficient way to write code when dealing with a large range of unknown values.  Mark for Review 
(1) Points  
True
False

13. What is the output?  Mark for Review 
   
public static void main(String args[]) {
(1) Points  
   char ch ='c';  
   switch(ch) {  
     case 'a':  
     case 'e': 
     case 'i':  
     case 'o': 
     case 'u': 
 
       System.out.println("Vowels");
       break;  
     default:  
 
       System.out.println("Consonants");
   }  
}  
Compilation error
Vowels
Vowels
Consonants

14. What is the output?   Mark for Review 
   
public static void main(String args[]) {
(1) Points  
   char grade ='E';  
 
   if (grade == 'A') {
 
      System.out.println("Excellent performer");
   }else if (grade == 'B') {  
 
      System.out.println("Good Performer");
   }else if (grade == 'C') {  
 
   System.out.println("Average Performer");
   }else {  
 
      System.out.println("Below Average Performer");
   }  
}  
Excellent performer
Not a Good Performer
Below Performer
Below Average Performer

15. Which two statements are true about the default statement?  Mark for Review 
(1) Points  
(Choose all correct answers)
A default statement is required in every switch statement.
When the input does not match any of the cases, the default statement is executed.
A default statement is executed by default when the program is executed.
The default statement is optional in switch statement.

Previous Page 3 of 3 Summary Finish Test


http://ilearning.oracle.com/ilearn/en/learner/jsp/player.jsp?rco_id=2005667757&classroom_id=2035474607&scorm_attempt=1524034423157&sessionId=-192216619015240344

You might also like