Wednesday, January 3, 2018

Kunci Jawaban All Quiz Oracle Academy Java Fundamental 2017 Part 20

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

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

  
               
        2.     Which of the following declares and initializes a two dimensional array with 3 rows and 2 columns?     Mark for Review
(1) Points
                  
          
    int a={{1,1,1},{1,1,1}};

          
    int[][] a={{1,1,1},{1,1,1}};

          
    int a={{1,1},{1,1},{1,1}};

          
    int[][] a={{1,1},{1,1},{1,1}}; (*)

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

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

          
    String words=new String[10];

          
    char[][] words;

          
    String[][] words=new String[10][3]; (*)

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        4.     Which of the following statements add all of the elements of the one dimensional array prices, and then prints the sum to the screen?     Mark for Review
(1) Points
                  
          
    int total = 0;
for(int i = 0; i total+=prices[i];
System.out.println(total); (*)

          
    int total = 0;
for(int i = 0; i total+=prices[i];

          
    int total = 0;
for(int i = 1; i total = total+prices[i];
System.out.println(prices);

          
    int total = 0;
for(int i = 0; i total+=prices[i];
System.out.println(prices);

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        5.     Which of the following declares and initializes a one dimensional array named words of size 10 so that all entries can be Strings?     Mark for Review
(1) Points
                  
          
    char words=new char[10];

          
    String[] words=new String[10]; (*)

          
    String words=new String[10];

          
    char[] words=new char[10];

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


 Mark for Review
(1) Points
                  
          
    321123

          
    312213

          
    This code doesn't compile.

          
    642246 (*)

          
    642

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        7.     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;

          
    String[][] values={"apples","oranges","pears"};

          
    String[][] values=new String[3][2];

          
    String[][] values=new String[2][3]; (*)

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

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


 Mark for Review
(1) Points
                  
          
    111

          
    1111

          
    11 (*)

          
    This code doesn't compile.

          
    321111

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

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


 Mark for Review
(1) Points
                  
          
    262423242322

          
    643432

          
    This code does not compile.

          
    1286864

          
    666666 (*)

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        10.     The following creates a reference in memory named z that can refer to seven different doubles via an index. True or false?

double z[] = new double[7];     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

11.     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

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        12.     Which of the following would give you an array index out of bounds exception?     Mark for Review
(1) Points
                  
          
    Refering to an element of an array that is at an index less than the length of the array minus one.

          
    Using a single equal symbol to compare the value of two integers.

          
    Refering to an element of an array that is at an index greater than the length of that array minus one. (*)

          
    Unintentionally placing a semicolon directly after initializing a for loop.

          
    Misspelling a variable name somewhere in your code.

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        13.     What do exceptions indicate in Java?     Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    Exceptions do not indicate anything, their only function is to be thrown.

          
    The code was not written to handle all possible conditions. (*)

          
    A mistake was made in your code. (*)

          
    The code has considered and dealt with all possible cases.

          
    There are no errors in your code.

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        14.     If an exception is thrown by a method, where can the catch for the exception be?     Mark for Review
(1) Points
                  
          
    The catch can be in the method that threw the exception or in any other method that called the method that threw the exception. (*)

          
    The catch must be in the method that threw the exception.

          
    There does not need to be a catch in this situation.

          
    The catch must be immediately after the throw.

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        15.     Suppose you misspell a method name when you call it in your program. Which of the following explains why this gives you an exception?     Mark for Review
(1) Points
                  
          
    Because the interpreter does not recognize this method since it was never initialized, the correct spelling of the method was initialized.

          
    Because the interpreter tries to read the method but when it finds the method you intended to use it crashes.

          
    This will not give you an exception, it will give you an error when the program is compiled. (*)

          
    Because the parameters of the method were not met.

     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.

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        2.     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

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        3.     Which of the following correctly matches the symbol with its function?     Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    = (single equals sign) compares the value of primitive types such as int or char.

          
    == (two equal signs) compares the values of non-primitive objects.

          
    .equals() compares the value of non-primitive objects. (*)

          
    == (two equal signs) compares the memory location of non-primitive objects. (*)

          
    == (two equal signs) compares values of primitive types such as int or char. (*)

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        4.     Suppose you misspell a method name when you call it in your program. Which of the following explains why this gives you an exception?     Mark for Review
(1) Points
                  
          
    Because the parameters of the method were not met.

          
    This will not give you an exception, it will give you an error when the program is compiled. (*)

          
    Because the interpreter tries to read the method but when it finds the method you intended to use it crashes.

          
    Because the interpreter does not recognize this method since it was never initialized, the correct spelling of the method was initialized.

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 2.

                  
        5.     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 (*)
6.     The following array declaration is valid:

int[] y = new int[5];     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

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

          
    int a={{1,1},{1,1},{1,1}};

          
    int a={{1,1,1},{1,1,1}};

          
    int[][] a={{1,1,1},{1,1,1}};

                  
              
Correct        Correct

                  
        8.     Which of the following statements adds 5 to every element of the one dimensional array prices and then prints it to the screen?     Mark for Review
(1) Points
                  
          
    for(int i=1;i<prices.length;i++)
System.out.println(prices[i]+5);

          
    for(int i=0;i<prices.length;i++)
System.out.println(prices[1]+5);

          
    for(int i=0;i<prices.length;i++)
System.out.println(prices[i]+5); (*)

          
    System.out.println(prices[i]+5);

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        9.     Which of the following declares and initializes a one dimensional array named words of size 3 so that all entries can be Strings?     Mark for Review
(1) Points
                  
          
    String[] words={"Oracle","Academy"}];

          
    String strings=new String[3];

          
    String[] words={"Over","the","mountain"}; (*)

          
    String[] words=new String[3];

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

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

     Mark for Review
(1) Points
                  
          
    7531 (*)

          
    6

          
    This code does not compile.

          
    753

          
    7766554433221

11.     Which of the following declares and initializes a one dimensional array that can hold 5 Object reference types?     Mark for Review
(1) Points
                  
          
    String[] array=String[4];

          
    String[] array=new String[5];

          
    Object[] array=new Object[4];

          
    Object array=new Object[5]; (*)

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        12.     The following array declaration is valid. True or false?
int k[] = new int[10];     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        13.     The following segment of code initializes a 2 dimensional array of references. True or false?

String[][] array={{"a", "b", "C"},{"a", "b", "c"}};     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

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


 Mark for Review
(1) Points
                  
          
    1

          
    3

          
    This code doesn't compile.

          
    6 (*)

          
    5

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        15.     Which of the following declares a one dimensional array named names of size 8 so that all entries can be Strings?     Mark for Review
(1) Points
                  
          
    String names=new String[8];

          
    String[] name=String[8];

          
    String[] names=new String[8]; (*)

          
    String[] name=new Strings[8];

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
Previous    Page 3 of 3    Summary

1.     Which of the following correctly matches the symbol with its function?     Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    == (two equal signs) compares the memory location of non-primitive objects. (*)

          
    .equals() compares the value of non-primitive objects. (*)

          
    = (single equals sign) compares the value of primitive types such as int or char.

          
    == (two equal signs) compares the values of non-primitive objects.

          
    == (two equal signs) compares values of primitive types such as int or char. (*)

                  
              
Correct        Correct

                  
        2.     Suppose you misspell a method name when you call it in your program. Which of the following explains why this gives you an exception?     Mark for Review
(1) Points
                  
          
    This will not give you an exception, it will give you an error when the program is compiled. (*)

          
    Because the parameters of the method were not met.

          
    Because the interpreter tries to read the method but when it finds the method you intended to use it crashes.

          
    Because the interpreter does not recognize this method since it was never initialized, the correct spelling of the method was initialized.

                  
              
Correct        Correct

                  
        3.     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

                  
              
Correct        Correct

                  
        4.     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

                  
              
Correct        Correct

                  
        5.     If an exception is thrown by a method, where can the catch for the exception be?     Mark for Review
(1) Points
                  
          
    The catch can be in the method that threw the exception or in any other method that called the method that threw the exception. (*)

          
    The catch must be in the method that threw the exception.

          
    There does not need to be a catch in this situation.

          
    The catch must be immediately after the throw.

                  
              
Correct        Correct

6.     Which of the following declares and initializes a one dimensional array named words of size 10 so that all entries can be Strings?     Mark for Review
(1) Points
                  
          
    String words=new String[10];

          
    char words=new char[10];

          
    String[] words=new String[10]; (*)

          
    char[] words=new char[10];

                  
              
Correct        Correct

                  
        7.     Which of the following declares a one dimensional array name scores of type int that can hold 14 values?     Mark for Review
(1) Points
                  
          
    int score= new int[14];

          
    int scores;

          
    int[] scores=new int[14]; (*)

          
    int[] scores=new scores int[14];

                  
              
Correct        Correct

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


 Mark for Review
(1) Points
                  
          
    This code doesn't compile.

          
    312213

          
    642

          
    321123

          
    642246 (*)

                  
              
Correct        Correct

                  
        9.     Which of the following declares and initializes a one dimensional array named values of size 5 so that all entries contain 1?     Mark for Review
(1) Points
                  
          
    int values[]={1,1,1,1,1,1};

          
    int[] values={1};

          
    int values={1,1,1,1,1};

          
    int[] values={1,1,1,1,1}; (*)

                  
              
Correct        Correct

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


 Mark for Review
(1) Points
                  
          
    3

          
    1

          
    5

          
    6 (*)

          
    This code doesn't compile.

What is the output of the following segment of code?


 Mark for Review
(1) Points
                  
          
    643432

          
    262423242322

          
    666666

          
    1286864 (*)

          
    This code does not compile.

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

                  
        12.      The following creates a reference in memory named y that can refer to five different integers via an index. True or false?

int[] y = new int[5];     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        13.      Which of the following declares and initializes a one dimensional array named words of size 3 so that all entries can be Strings?     Mark for Review
(1) Points
                  
          
    String[] words={"Oracle","Academy"}];

          
    String strings=new String[3];

          
    String[] words=new String[3];

          
    String[] words={"Over","the","mountain"}; (*)

                  
              
Correct        Correct

                  
        14.      The following creates a reference in memory named z that can refer to seven different doubles via an index. True or false?

double z[] = new double[7];     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        15.      Which of the following declares a one dimensional array named "score" of type int that can hold 9 values?     Mark for Review
(1) Points
                  
          
    int score;

          
    int score=new int[9];

          
    int[] score;

          
    int[] score=new int[9]; (*)

                  
              
Incorrect        Incorrect. Refer to Section 6 Lesson 1.

    What is a hierarchy?     Mark for Review
(1) Points
                  
          
    A programming philosophy that promotes simpler, more efficient coding by using existing code for new applications.

          
    A structure that categorizes and organizes relationships among ideas and concepts of things with the most general at the top and the most specific at the bottom. (*)

          
    A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods.

          
    A keyword that allows subclasses to access methods, data, and constructors from their parent class.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        2.     Which of the following correctly describes the use of the keyword super?     Mark for Review
(1) Points
                  
          
    A keyword that allows subclasses to access methods, data, and constructors from their parent class. (*)

          
    A keyword that restricts access to only inside the same class.

          
    A keyword that allows access from anywhere.

          
    A keyword that signals the end of a program.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        3.     Methods are generally declared as public so other classes may use them. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        4.     Identify the error(s) in the class below. Choose all that apply.


 Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    No method named min is defined. (*)

          
    The parameters must be the same for all methods with the same name.

          
    Final cannot be used as an access modifier.

          
    Two methods cannot have the same name.

          
    Private cannot be used as an access modifier.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 2.

                  
        5.     Which of the following is the correct definition of a parameter?     Mark for Review
(1) Points
                  
          
    A variable in a method declaration that gets passed into the method. (*)

          
    A way to call a method with a variable number of arguments using an elipse.

          
    A keyword that specifies accessibility of code.

          
    A type of access specifier.

          
    It is used to assign initial values to instance variables of a class; the structure is very similar to that of a method.

                  
              
Correct        Correct

6.     It is possible to have more than one constructor with the same name in a class, but they must have different parameters. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        7.     Static classes are designed as thread safe class instances. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 3.

                  
        8.     There is only one copy a static class variable in the JVM. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        9.     You can return an instance of a private class through a static method of a different class. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 3.

                  
        10.     Is there a difference between overriding a method and overloading a method?     Mark for Review
(1) Points
                  
          
    No, they are the same.

          
    Yes. Overriding is done within a single class and overloading is done through a series of superclasses and their subclasses.

          
    Yes. Overriding is done in the subclass and allows for redefining a method inherited from the superclass and overloading is done within a class and allows for multiple methods with the same name. (*)

          
    Yes. Overriding allows for the creation of an array of different object types and overloading restricts an array to only contain the same object types.

                11.     Abstract class cannot extend another abstract class. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Correct        Correct

                  
        12.     Abstract classes cannot implement interfaces. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        13.     The following statement compiles and executes. What can you say for sure?
submarine.dive(depth);     Mark for Review
(1) Points
                  
          
    dive must be the name of an instance field.

          
    submarine must be a method.

          
    dive must be a method. (*)

          
    The variable depth must be an int.

          
    submarine must be the name of a class.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        14.     Instance variable names may only contain letters and digits. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        15.     If the return type from a method is boolean then 2.5 is a valid return value. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

1.     What operator do you use to call an object's constructor method and create a new object?     Mark for Review
(1) Points
                  
          
    class

          
    new (*)

          
    instanceOf

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        2.     Complete the sentence. A constructor...     Mark for Review
(1) Points
                  
          
    must have the same name as the class it is declared within.

          
    is used to create objects.

          
    may be declared public.

          
    is all of the above. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        3.     The constructor of a class has the same name as the class. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        4.     Static classes can exist as stand alone classes. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 3.

                  
        5.     You can create static classes as independent classes. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Correct        Correct

6.     Non-final static class variables should be private to prevent changes from other classes. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False
          
        1.     Static methods can change instance variables at run-time. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 3.

                  
        2.     Non-final static class variables should be private to prevent changes from other classes. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        3.     Static classes can exist as stand alone classes. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Correct        Correct

                  
        4.     Which of the following correctly defines a superclass (or parent class)?     Mark for Review
(1) Points
                  
          
    The most specific class of a hierarchy system of classes.

          
    A class that inherits methods and fields from a more general class.

          
    A keyword that allows or restricts access to data and methods.

          
    A class that passes down its methods to more specialized classes. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        5.     Where should the constructor for a superclass be called?     Mark for Review
(1) Points
                  
          
    Anywhere inside the subclass.

          
    The super constructor does not need to be called inside the subclass.

          
    Inside the main method of the subclass.

          
    The last line in the constructor of the subclass.

          
    The first line of the constructor in the subclass. (*)

6.     Which is the most accurate description of the code reuse philosophy?     Mark for Review
(1) Points
                  
          
    A programming philosophy that promotes having no concern about the security of code.

          
    A programming philosophy that promotes simpler, more efficient coding by using existing code for new applications. (*)

          
    A programming philosophy that promotes stealing your classmates' code.

          
    A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        7.     What is Polymorphism?     Mark for Review
(1) Points
                  
          
    A way of redefining methods with the same return type and parameters.

          
    The concept that a variable or reference can hold multiple types of objects. (*)

          
    A way to create multiple methods with the same name but different parameters.

          
    A class that cannot be initiated.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        8.     Abstract classes can be instantiated. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        9.     What is the Java keyword final used for in a program?     Mark for Review
(1) Points
                  
          
    It permits access to the class variables and methods from anywhere.

          
    There is no such keyword in Java.

          
    It permits redefining methods of a parent class inside the child class, with the same name, parameters, and return type.

          
    It terminates the program.

          
    It restricts a class from being extendable and restricts methods from being overridden. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        10.     What is garbage collection in the context of Java?     Mark for Review
(1) Points
                  
          
    The operating system periodically deletes all of the Java files available on the system.

          
    Any package imported in a program and not used is automatically deleted.

          
    When all references to an object are gone, the memory used by the object is automatically reclaimed. (*)

          
    The JVM checks the output of any Java program and deletes anything that does not make sense.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

11.     What operator do you use to call an object's constructor method and create a new object?     Mark for Review
(1) Points
                  
          
    +

          
    instanceOf

          
    new (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        12.     Which of the following creates an instance of the class below?


 Mark for Review
(1) Points
                  
          
    ThisClass t;

          
    ThisClass t=new ThisClass(5); (*)

          
    ThisClass t=new ThisClass();

          
    ThisClass t=new ThisClass(3,4);

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        13.     How is it possible for overloading to work?     Mark for Review
(1) Points
                  
          
    The code has to be declared as private.

          
    Java Virtual Machine searches until it finds a constructor name and argument type match. (*)

          
    The interpreter doesn't care what you name your constructors.

          
    There is no such thing as overloading.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 2.

                  
        14.     Cameron wishes to write a method that takes in two objects and returns the one with the greatest value. Is this possible?     Mark for Review
(1) Points
                  
          
    No, it is not possible to return objects.

          
    Yes, but he will have to use two different methods, one to take in the objects and the other to return an object.

          
    Yes, methods can take objects in as parameters and can also return objects all within the same method. (*)

          
    No, it is not possible to have objects as parameters or to return objects.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 2.

                  
        15.     A team is working on a coding project. They desire that all portions of their code should have access to the classes that they write. What access modifier should be used for each class?     Mark for Review
(1) Points
                  
          
    public (*)

          
    protected

          
    private

          
    default

          
    All of the above


                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 3.

                  
        7.     Where should the constructor for a superclass be called?     Mark for Review
(1) Points
                  
          
    The first line of the constructor in the subclass. (*)

          
    The super constructor does not need to be called inside the subclass.

          
    The last line in the constructor of the subclass.

          
    Inside the main method of the subclass.

          
    Anywhere inside the subclass.

                  
              
Correct        Correct

                  
        8.     According to the following class declaration, runSpeed can be modified in class Cat. True or false

public class Tiger extends Cat{
public int runSpeed;
}     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        9.     Which of the following show the correct UML representation of the super class Planet and its subclass Earth?     Mark for Review
(1) Points
                  
          
  

(*)

          
  


          
  


          
    None of the above.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        10.     Which of the following specifies accessibility to variables, methods, and classes?     Mark for Review
(1) Points
                  
          
    Methods

          
    Overload constructors

          
    Parameters

          
    Access modifiers (*)
11.     Consider the following:

There is a method A that calls method B. Method B is a variable argument method.

With this, which of the following are true?     Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    Method A can invoke method B twice, each time with a different number of arguments. (*)

          
    A compliler error will result since method B does not know how large an array to create when it is invoked by method A.

          
    When invoked, method B creates an array to store some or all of the arguments passed to it from method A. (*)

          
    All of the above.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 2.

                  
        12.     Which of the following is the definition of a constructor?     Mark for Review
(1) Points
                  
          
    A variable in a method declaration that gets passed into the method.

          
    A keyword that specifies accessibility of code.

          
    A special method that is used to assign initial values to instance variables in a class. (*)

          
    A way to call a method with a variable number of arguments using an elipse.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 2.

                  
        13.     Which of the following are true about abstract methods?     Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    They may contain implementation.

          
    They cannot have a method body. (*)

          
    They must be overridden in a non-abstract subclass. (*)

          
    They must be overloaded.

          
    They must be declared in an abstract class. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        14.     Abstract class cannot extend another abstract class. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        15.     If a class is immutable then it must be abstract. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

1.     Which of the following demonstrates the correct way to create an applet Battlefield?     Mark for Review
(1) Points
                  
          
    public Applet Battlefield{...}

          
    public class Battlefield(Applet){...}

          
    public class Battlefield extends Applet{...} (*)

          
    public class Applet extends Battlefield{...}

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        2.     Which of the following correctly defines a subclass (or child class)?     Mark for Review
(1) Points
                  
          
    A class that inherits methods and fields from a more general class. (*)

          
    A keyword that allows or restricts access to data and methods.

          
    The most general class of a hierarchy system.

          
    A class that passes down its methods to more specialized classes.

                  
              
Correct        Correct

                  
        3.     What is encapsulation?     Mark for Review
(1) Points
                  
          
    A programming philosophy that promotes simpler, more efficient coding by using exiting code for new applications.

          
    A structure that categorizes and organizes relationships among ideas, concepts of things with the most general at the top and the most specific at the bottom.

          
    A keyword that allows or restricts access to data and methods.

          
    A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        4.     What does it mean to override a method?     Mark for Review
(1) Points
                  
          
    It restricts the privacy of the method to only be accessible from inside the same class.

          
    It is a way to create multiple methods with the same name but different parameters.

          
    It allows an array to contain different object types.

          
    It is a way of redefining methods of a parent class inside the child class, with the same name, parameters, and return type. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        5.     Abstract class cannot extend another abstract class. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

6.     What is Polymorphism?     Mark for Review
(1) Points
                  
          
    A way of redefining methods with the same return type and parameters.

          
    The concept that a variable or reference can hold multiple types of objects. (*)

          
    A way to create multiple methods with the same name but different parameters.

          
    A class that cannot be initiated.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        7.     Static methods can write to class variables. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        8.     Non-final static class variables should be private to prevent changes from other classes. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        9.     You can assign new values to static variables by prefacing them with the this keyword and a dot or period. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        10.     You are assigned to write a method that compares two objects of type Career. One requirement of your assignment is to have your method compare the "greatestPossibleSalary" instance data of Career objects. The "greatestPossibleSalary" field is data type int.

What would be the best return type from your compare method?     Mark for Review
(1) Points
                  
          
    Career, because if it returns the highest paying Career object it will be able to use the same method later to compare other aspects of Career objects. (*)

          
    Integer, because it is the easiest to code with.

          
    Array, because it can store the most information.

          
    String, because is should return a string of the name of the career that is highest paying because none of the other information of the career matters.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 2.

11.     It is possible to overload a method that is not a constructor. True or False?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        12.     How is it possible for overloading to work?     Mark for Review
(1) Points
                  
          
    The interpreter doesn't care what you name your constructors.

          
    Java Virtual Machine searches until it finds a constructor name and argument type match. (*)

          
    There is no such thing as overloading.

          
    The code has to be declared as private.

                  
              
Correct        Correct

                  
        13.     The return value of a method can only be a primitive type and not an object. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        14.     Consider:

public class MyClass{
public MyClass()
{/*code*/}
// more code...}

To instantiate MyClass, what would you write?     Mark for Review
(1) Points
                  
          
    MyClass m = new MyClass;

          
    MyClass m = new MyClass(); (*)

          
    MyClass m = MyClass;

          
    MyClass m = MyClass();

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        15.     The following statement compiles and executes. What can you say for sure?
submarine.dive(depth);     Mark for Review
(1) Points
                  
          
    submarine must be the name of a class.

          
    submarine must be a method.

          
    dive must be a method. (*)

          
    dive must be the name of an instance field.

          
    The variable depth must be an int.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

1.     Methods are generally declared as public so other classes may use them. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False

                  
              
Correct        Correct

                  
        2.     Which of the following correctly describes the use of the keyword super?     Mark for Review
(1) Points
                  
          
    A keyword that signals the end of a program.

          
    A keyword that allows subclasses to access methods, data, and constructors from their parent class. (*)

          
    A keyword that allows access from anywhere.

          
    A keyword that restricts access to only inside the same class.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 4.

                  
        3.     What does it mean to inherit a class?     Mark for Review
(1) Points
                  
          
    The subclass (or child class) gains access to any non-private methods and variables of the superclass (or parent class). (*)

          
    A way of organizing the hierarchy of classes.

          
    The access specifier has been set to private.

          
    Extending a method from a superclass.

                  
              
Correct        Correct

                  
        4.     A team is working on a coding project. They desire that all portions of their code should have access to the classes that they write. What access modifier should be used for each class?     Mark for Review
(1) Points
                  
          
    public (*)

          
    protected

          
    private

          
    default

          
    All of the above

                  
              
Correct        Correct

                  
        5.     What type(s) would work for a variable argument method?     Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    Integers, Strings, and Booleans (*)

          
    Constructors

          
    Arrays (*)

          
    Objects (*)

          
    All of the above
6.     You are assigned to write a method that compares two objects of type Career. One requirement of your assignment is to have your method compare the "greatestPossibleSalary" instance data of Career objects. The "greatestPossibleSalary" field is data type int.

What would be the best return type from your compare method?     Mark for Review
(1) Points
                  
          
    String, because is should return a string of the name of the career that is highest paying because none of the other information of the career matters.

          
    Integer, because it is the easiest to code with.

          
    Career, because if it returns the highest paying Career object it will be able to use the same method later to compare other aspects of Career objects. (*)

          
    Array, because it can store the most information.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 2.

                  
        7.     Consider

public class YourClass{
public YourClass(int i)
{/*code*/}
// more code...}

To instantiate YourClass, what would you write?     Mark for Review
(1) Points
                  
          
    YourClass y = new YourClass();

          
    YourClass y = new YourClass(3); (*)

          
    YourClass y = YourClass(3);

          
    YourClass y = YourClass();

          
    None of the above.

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        8.     What value will be returned when the setValue method is called?


 Mark for Review
(1) Points
                  
          
    36

          
    35

          
    37 (*)

          
    38

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        9.     Which of the following calls the method moveUp in the class below:


 Mark for Review
(1) Points
                  
          
    Puzzle p=new Puzzle(); p.moveUp(3,4,5);

          
    PuzzlePiece p=new PuzzlePiece(); p.moveUp(3,4,5);

          
    PuzzlePiece p=new PuzzlePiece(); p.moveUp(3,4); (*)

          
    Puzzle p=new Puzzle(); p.moveUp(3,4);

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 1.

                  
        10.     There is only one copy a static class variable in the JVM. True or false?     Mark for Review
(1) Points
                  
          
    True (*)

          
    False
11.     Which of the following statements about static methods is true?     Mark for Review
(1) Points
                  
          
    They exist once in each instance.

          
    They can be overridden by a subclass.

          
    They cannot access static variables declared outside the method.

          
    They can access any instance variable.

          
    They exist once per class. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 3.

                  
        12.     Static methods can read instance variables. True or false?     Mark for Review
(1) Points
                  
          
    True

          
    False (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 3.

                  
        13.     What allows Java to correctly and automatically determine which method to invoke based on the type of object being referred to at the time the method is called?     Mark for Review
(1) Points
                  
          
    Dynamic Method Dispatch (*)

          
    Polymorphism

          
    Abstract classes

          
    Inheritance

                  
              
Correct        Correct

                  
        14.     Identify the step (s) in creating a Triangle Applet that displays two triangles.     Mark for Review
(1) Points
                  
            (Choose all correct answers)  
                  
          
    Run and compile your code. (*)

          
    Draw the triangle using the inherited fillPolygon method. (*)

          
    Draw the 2nd triangle using the inherited fillPolygon method. (*)

          
    Extend Applet class to inherit all methods including paint. (*)

          
    Override the paint method to include the triangles. (*)

                  
              
Incorrect        Incorrect. Refer to Section 7 Lesson 5.

                  
        15.     Is there a difference between overriding a method and overloading a method?     Mark for Review
(1) Points
                  
          
    Yes. Overriding allows for the creation of an array of different object types and overloading restricts an array to only contain the same object types.

          
    No, they are the same.

          
    Yes. Overriding is done in the subclass and allows for redefining a method inherited from the superclass and overloading is done within a class and allows for multiple methods with the same name. (*)

          
    Yes. Overriding is done within a single class and overloading is done through a series of superclasses and their subclasses.

Artikel Terkait

Life with colorful experience

3 komentar

Kuncinya lengkap bgt xD

terimakasih bapak yg telah membantu. top markotop, walaupun masih ada kesalahan 1 1 jawabannya, tapi yg penting lulus.


EmoticonEmoticon