Skip to main content

Section 5 Oracle Java Fundamental Quiz

Section 5 Quiz
            (Answer all questions in this section)
                                                             
1.         Which of the following could be a reason to use a switch statement in a Java program?        Mark for Review
(1) Points
Because it terminates the current loop.
Because it allows the code to be run through until a certain conditional statement is true.
Because it allows the program to run certain segments of code and neglect to run others based on the input given. (*)
Because it allows the user to enter an input in the console screen and prints out a message that the user input was successfully read in.

2.         The three logic operators in Java are:    Mark for Review
(1) Points
!=,=,==
&&,!=,=
&&, ||, ! (*)
&,|,=

3.         Which of the two diagrams below illustrate the correct syntax for variables used in an if-else statement?



(1) Points
Example A (*)
Example B

4.         Determine whether this boolean expression evaluates to true or false:
!(3 < 4 && 5 > 6 || 6 <= 6 && 7 - 1 == 6)        Mark for Review
(1) Points
True
False (*)

5.         The six relational operators in Java are:            Mark for Review
(1) Points
>,<,=,!=,=<,=>
>,<,==,!=,<=,>= (*)
>,<,=,!=,<=,>=
>,<,=,!,<=,>=

6.         How would you use the ternary operator to rewrite this if statement?

if (skillLevel > 5)
numberOfEnemies = 10;
else
numberOfEnemies = 5;           Mark for Review
(1) Points
            numberOfEnemies = ( skillLevel >= 5) ? 5 : 10;
            numberOfEnemies = ( skillLevel > 5) ? 10 : 5; (*)
            numberOfEnemies = ( skillLevel >= 5) ? 10 : 5;
            numberOfEnemies = ( skillLevel < 5) ? 10 : 5;
            numberOfEnemies = ( skillLevel > 5) ? 5 : 10;

7.         What will print if the following Java code is executed?

if ((5.1 > 4.3 && 6.2 < 8.4) && !(7.2 < 3.5 || 1.2 == 2.1 || 2.2 != 2.25))
System.out.print("TRUE");
else
System.out.print("FALSE");   Mark for Review
(1) Points
            True
            False (*)

8.         Determine whether this boolean expression evaluates to true or false:

!(3 < 4 && 6 > 6 || 6 <= 6 && 7 - 2 == 6)      Mark for Review
(1) Points
            True (*)
            False

9.         Why are loops useful? Mark for Review
(1) Points
            They save programmers from having to rewrite code.
            They allow for repeating code a variable number of times.
            They allow for repeating code until a certain argument is met.
            All of the above. (*)

10.       In a for loop, the counter is automatically incremented after each loop iteration. True or False?      Mark for Review
(1) Points
            True
            False (*)

11.       What is a loop?           Mark for Review
(1) Points
            A keyword used to skip over the remaining code.
            A set of logic that is repeatedly executed until a certain condition is met. (*)
            A segment of code that may only ever be executed once per call of the program.
            None of the above.

12.       Which of the following best describes a while loop? Mark for Review
(1) Points
            A loop that contains a counter in parenthesis with the conditional statement.
            A loop that contains a segment of code that is executed before the conditional statement is tested.
            A loop that is executed repeatedly until the conditional statement is false. (*)
            A loop that executes the code at least one time even if the conditional statement is false.

13.       When the for loop condition statement is met the construct is exited. True or false?            Mark for Review
(1) Points
            True
            False (*)

14.       Updating the input of a loop allows you to implement the code with the next element rather than repeating the code always with the same element. True or false?      Mark for Review
(1) Points
            True (*)
            False

15.       What is one significant difference between a while loop and a do-while loop?        Mark for Review
(1) Points
            A DO-WHILE loop will always execute the code at least once, even if the conditional statement for the WHILE is never true. A WHILE loop is only executed if the conditional statement is true. (*)
            A DO-WHILE loop includes an int that serves as a counter and a WHILE loop does not.
            There is no difference between a DO-WHILE loop and a WHILE loop.

            A DO-WHILE loop does not exist in Java and a WHILE loop does.

Comments

Popular posts from this blog

Section 6 Quiz Oracle Database Programming with SQL

Section 6 Quiz             (Answer all questions in this section)                                                             1.         Given the following descriptions of the employees and jobs tables, which of the following scripts will display each employee ï¾’ s possible minimum and maximum salaries based on their job title? EMPLOYEES Table: Name   Null?    Type EMPLOYEE_ID          NOT NULL     NUMBER (6) FIRST_NAME             VARCHAR2 (20) LAST_NAME  NOT NULL     VARCHAR2 (25) EMAIL NOT NULL     VARCHAR2 (25) PHONE_NUMBER                  VARCHAR2 (20) HIRE_DATE   NOT NULL     DATE JOB_ID           NOT NULL     VARCHAR2 (10) SALARY                     NUMBER (8,2) COMMISSION_PCT                NUMBER (2,2) MANAGER_ID                       NUMBER (6) DEPARTMENT_ID                 NUMBER (4) JOBS Table: Name   Null?    Type JOB_ID           NOT NULL     VARCHAR2 (10) JOB_TITLE     NOT NULL     VARCHAR2 (35) MIN_SALARY                      

Section 10 Quiz Database Programming With SQL

Section 10 Quiz             (Answer all questions in this section) 1.         A multiple-row operator expects how many values?   Mark for Review (1) Points             One or more (*)             Only one             Two or more             None 2.         The salary column of the f_staffs table contains the following values: 4000 5050 6000 11000 23000 Which of the following statements will return the last_name and first_name of those employees who earn more than 5000?  Mark for Review (1) Points             SELECT last_name, first_name FROM f_staffs WHERE salary IN (SELECT last_name, first_name FROM f_staffs WHERE salary <5000 o:p="">             SELECT last_name, first_name FROM f_staffs WHERE salary = (SELECT salary FROM f_staffs WHERE salary < 5000);             SELECT last_name, first_name FROM f_staffs WHERE salary IN (SELECT salary FROM f_staffs WHERE salary > 5000); (*)             SELEC

Section 2 Quiz Database Design Oracle

Section 2 Quiz             (Answer all questions in this section) 1.         An Entity Relationship model is independent of the hardware or software used for implementation. True or False?  Mark for Review (1) Points             True (*)             False 2.         A well structured ERD will show only some parts of the finished data model. You should never try to model the entire system in one diagram, no matter how small the diagram might be. True or False?           Mark for Review (1) Points             True             False (*) 3.         The purpose of an ERD is to document the proposed system and facilitate discussion and understanding of the requirements captured by the developer. True or False?          Mark for Review (1) Points             True (*)             False 4. Documenting Business Requirements helps developers control the scope of the system and prevents users from claiming that the new system does not meet their business req