Langsung ke konten utama

Section 6 Oracle Java Fundamental Quiz

Section 6 Quiz
  (Answer all questions in this section)
  1.   The following segment of code initializes a 2 dimensional array of primitive data types. True or false?
double[][] a=new double[4][5];  Mark for Review
(1) Points
True (*)
False

2.   Which of the following declares and initializes a two dimensional array named values with 2 rows and 3 columns where each element is a reference to an Object?  Mark for Review
(1) Points
String[][] values={"apples","oranges","pears"};
String[][] values=new String[2][3]; (*)
String[][] values;
String[][] values=new String[3][2];

3.   double array[] = new double[8];
After execution of this statement, which of the following are true?  Mark for Review
(1) Points
array.length is 8 (*)
array[0] is undefined
array[2] is 8
array[4] is null

4.   What is the output of the following segment of code if the command line arguments are "apples oranges pears"?



   Mark for Review
(1) Points
oranges
This code does not compile.
args
pears (*)
apples

5.   What is the output of the following segment of code if the command line arguments are "a b c d e f g"?



   Mark for Review
(1) Points
c
e (*)
d
f
This code doesn't compile.

6.   Which of the following statements is not a valid array declaration?  Mark for Review
(1) Points
float []averages;
double marks[5];
counter int[]; (*)
int number[];

7.   What is the output of the following segment of code?



   Mark for Review
(1) Points
11 (*)
111
1111
321111
This code doesn't compile.

8.   What is the output of the following segment of code?



   Mark for Review
(1) Points
555555
777777 (*)
This code doesn't compile.
456789
987654

9.   The following creates a reference in memory named q that can refer to eight different doubles via an index. True or false?
double[] q = new double[8];  Mark for Review
(1) Points
True (*)
False

10.   What is the output of the following segment of code?



   Mark for Review
(1) Points
666666 (*)
643432
262423242322
1286864
This code does not compile.

11.   Suppose you are writing a program where the user is prompted to the give coordinates where they believe the princess is inside of the castle.
Your program moves the prince to the coordinates that the user specified. If the princess is not found at those coordinates, the user is given a clue that helps them guess coordinates closer to the princess. The user is allowed to enter their new guess of where the princess is.
Assume your program does not take into consideration the possibility that the user may enter coordinates outside of the castle where the princess could not be. What would be the result of the user entering coordinates outside of the castle? How could this be handled in your code?  Mark for Review
(1) Points
  (Choose all correct answers)
An error would occur. Errors cannot be handled by code.
An exception would occur. This could be handled by throwing the exception in your code if the user enters invalid coordinates. When the exception is caught, the prince could be moved to the coordinate inside the castle that is closest to those that the user specified. (*)
An exception would occur. This could be handled by throwing an exception in your code if the user enters invalid coordinates. When the exception is caught, the user could be prompted to enter coordinates within the given range of the castle. (*)
An exception would occur but could not be handled inside your code. The user would have to restart the program and enter proper coordinates.

12.   Which of the following defines an Exception?  Mark for Review
(1) Points
A very severe non-fixable problem with interpreting and running your code.
An interpreter reading your code.
A problem that can be corrected or handled by your code. (*)
Code that has no errors and therefore runs smothly.

13.   What do exceptions indicate in Java?  Mark for Review
(1) Points
  (Choose all correct answers)
The code was not written to handle all possible conditions. (*)
There are no errors in your code.
A mistake was made in your code. (*)
The code has considered and dealt with all possible cases.
Exceptions do not indicate anything, their only function is to be thrown.

14.   It is possible to throw and catch a second exception inside a catch block of code. True or false?  Mark for Review
(1) Points
True (*)
False

15.   What exception message indicates that a variable may have been mispelled somewhere in the program?  Mark for Review
(1) Points
variableName cannot be resolved to a variable (*)
method methodName(int) is undefined for the type className
Syntax error, insert ";" to complete statement
All of the above

1.         What does the interpreter look for when an exception is thrown?     Mark for Review
(1) Points
            It does not look for anything. It stops interpreting your code.
            The end of the code.
            It does not look for anything. It just keeps reading through your code.
            A catch statement in the code. (*)

2.         Which of the following could be a reason to throw an exception?    Mark for Review
(1) Points
            To make the user interface harder to navigate.
            To eliminate exceptions from disrupting your program. (*)
            You have encountered a Stack Overflow Error.
            You have a fatal error in your program.

3.         A logic error occurs if an unintentional semicolon is placed at the end of a loop initiation because the interpreter reads this as the only line inside the loop, a line that does nothing. Everything that follows the semicolon is interpreted as code outside of the loop. True or false?  Mark for Review
(1) Points
            True
            False (*)

4.         Which line of code shows the correct way to throw an exception?   Mark for Review
(1) Points
            throw Exception("Array index is out of bounds");
            throws new Exception("Array index is out of bounds");
            new throw Exception("Array index is out of bounds");
            throw new Exception("Array index is out of bounds"); (*)

5.         If an exception has already been thrown, what will the interpreter read next in the program?         Mark for Review
(1) Points
            Where the program catches the exception. (*)
            The next line of the program even if it is not the catch block of code.
            The end of the program.
            The user input.

Section 6 Quiz
  (Answer all questions in this section)
6.   What is the output of the following segment of code? 



   Mark for Review 
(1) Points 
987654
555555
777777 (*)
456789
This code doesn't compile.

7.   Which of the following declares and initializes a two dimensional array where each element is a reference type?  Mark for Review 
(1) Points 
String words=new String[10];
char[][] words;
String[][] words=new String[10][3]; (*)
char[][] words=new char[10][4];

8.   Which of the following declares and initializes a two dimensional array?  Mark for Review 
(1) Points 
int[][] array={1,1,1,1,1,1,1,1,1};
int[][] array={1,1,1},{1,1,1},{1,1,1};
int[][] array={{1,1,1},{1,1,1},{1,1,1}}; (*)
int[] array={{1,1,1},{1,1,1},{1,1,1}};

9.   The following array declaration is valid:
int[] y = new int[5];  Mark for Review 
(1) Points 
True (*)
False

10.   The following segment of code initializes a 2 dimensional array of primitive data types. True or false?
double[][] a=new double[4][5];  Mark for Review 
(1) Points 
True (*)
False


11.       Which of the following statements is not a valid array declaration?  Mark for Review
(1) Points
            double marks[5];
            int number[];
            counter int[]; (*)
            float []averages;

12.       double array[] = new double[8];

After execution of this statement, which of the following are true?  Mark for Review
(1) Points
            array[0] is undefined
            array.length is 8 (*)
            array[4] is null
            array[2] is 8
                                               
13.       What is the output of the following segment of code?


 Mark for Review
(1) Points
            321123
            312213
            642246 (*)
            642
            This code doesn't compile.

14.       The following segment of code prints all five of the command line arguments entered into this program. True or false?


  Mark for Review
(1) Points
            True
            False (*)

15.       Which of the following statements print every element of the one dimensional array prices to the screen? Mark for Review
(1) Points
            System.out.println(prices.length);
            for(int i=0; i <= prices.length; i++){System.out.println(prices[i]);}
            for(int i=1; i <= prices.length; i++){System.out.println(prices[i]);}
            for(int i=0; i < prices.length; i++){System.out.println(prices[i]);} (*)

Komentar

  1. gan no 10 salah harusnya 1286864

    BalasHapus
  2. الالالاااااااااااااااااااااااااااااااااااااااااااااالاللاااالللللللللللللللللللل

    BalasHapus

Posting Komentar

Postingan populer dari blog ini

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 6 Quiz Database Design Oracle

Section 6 Quiz             (Answer all questions in this section) 1.         Examine the following Entity and decide which rule of Normal Form is being violated: ENTITY: CLIENT ATTRIBUTES:     # CLIENT ID     FIRST NAME     LAST NAME     STREET     CITY     ZIP CODE  Mark for Review (1) Points             1st Normal Form.             2nd Normal Form.             3rd Normal Form.             None of the above, the entity is fully normalised. (*) 2.         A transitive dependency exists when any attribute in an entity is dependent on any other non-UID attribute in that entity.            Mark for Review (1) Points             True (*)             False 3.         When any attribute in an entity is dependent on any other non-UID attribute in that entity, this is known as:        Mark for Review (1) Points             Functional dependency             Dependency             Transitive dependency (*)             Non-dependency