Quiz
Sem título
Crie uma conta grátis para terminar este quiz
Salve seu progresso e veja sua nota final.
Já tem uma conta? Inicie sessão
Perguntas do quiz (55)
1Java arrays can store primitive types and Strings, but cannot store any other type of Object other
than Strings.- AVerdadeiro
- BFalso
2A Java main method uses the parameter (String[ ] variable) so that a user can run the program
and supply "command-line" parameters. Since the parameter is a String array, however, the
user does not have to supply any parameters- AVerdadeiro
- BFalso
3An array index cannot be a float, double, boolean or String.
- AVerdadeiro
- BFalso
4If the following statement is performed: CD[ ] mycollection = new CD[200]; where CD is a
previously defined class, then mycollection[5] is a CD object.- AVerdadeiro
- BFalso
5It is possible to sort an array of int, float, double or String, but not an array of an Object class
such as a CD class.- AVerdadeiro
- BFalso
6To swap the 3 rd and 4th elements in the int array values, you would do:
values[3] = values[4];
values[4] = values[3];- AVerdadeiro
- BFalso
7 In a two-dimensional array, both dimensions must have the same number of elements, as
in[10][10].- AVerdadeiro
- BFalso
8An array, when instantiated, is fixed in size, but an ArrayList can dynamically change in size
when new elements are added to it.- AVerdadeiro
- BFalso
9Just as arrays can only have a fixed number of elements, set at the time the array is declared, a
parameter list also can only have a fixed number of elements, set at the time the method is
declared- AVerdadeiro
- BFalso
10Interface classes cannot be extended but classes that implement interfaces can be extended.
- AVerdadeiro
- BFalso
11A derived class has access to all of the methods of the parent class, but only the protected or
public instance data of the parent class- AVerdadeiro
- BFalso
12If class AParentClass has a protected instance data x, and AChildClass is a derived class of
AParentClass, then AChildClass can access x but can not redefine x to be a different type- AVerdadeiro
- BFalso
13A is a derived class of X.
- AVerdadeiro
- BFalso
14Y is a derived class of Z.
- AVerdadeiro
- BFalso
15If A, B, Y and Z all contain the same instance data d1, then d1 should be declared in X and
inherited into Y, Z, A and B.- AVerdadeiro
- BFalso
16If classes C1 and C2 both implement an interface Cint, which has a method whichIsIt, and if C1 c
= new C1( ); is performed at one point of the program, then a later instruction c.whichIsIt( ); will
invoke the whichIsIt method defined in C1.- AVerdadeiro
- BFalso
17The protected visibility modifier provides the best possible encapsulation that permits
inheritance.- AVerdadeiro
- BFalso
18You may use the super reserved word to access a parent class'private members.
- AVerdadeiro
- BFalso
19Java doesn't support multiple inheritance; but it does support the implementation of multiple
Interfaces.- AVerdadeiro
- BFalso
20A polymorphic reference can refer to different types of objects over time
- AVerdadeiro
- BFalso
21Java allows one to create polymorphic references using inheritance and using interfaces.
- AVerdadeiro
- BFalso
22A reference variable can refer to any object created from any class related to it by inheritance.
- AVerdadeiro
- BFalso
23The fact that the System.out.println( ) method is able to handle such a wide variety of objects,
and print them correctly, is an example of the polymorphic nature of the println( ) method.- AVerdadeiro
- BFalso
24An interface name can be used to declare an object reference variable.
- AVerdadeiro
- BFalso
25A class reference can refer to any object of any class that descends from the class.
- AVerdadeiro
- BFalso
26One of the advantages of linear search is that it does not require its data to be sorted.
- AVerdadeiro
- BFalso
27Binary search can be used on unsorted datait will just perform more slowly.
- AVerdadeiro
- BFalso
28What is returned by values[3]?
- A2
- B6
- C3
- D9
- E12
29What is the value of values.length?
- A6
- B5
- C7
- D0
- E18
30Which of the following loops would adequately add 1 to each element stored in values?
- Afor (j=0; j<=values.length; j++) values[j]++;
- Bfor (j=0; j<values.length; j++) values[j]++;
- Cfor (j=1; j<values.length-1; j++) values[j]++;
- Dfor (j=0; j<values.length-1; j++) values[j]++;
- Efor (j=1; j<values.length; j++) values[j]++;
31The statement System.out.println(values[7]); will
- Acause a syntax error
- Boutput nothing
- Coutput 7
- Doutput 18
- Ecause an ArrayOutOfBoundsException to be thrown
32Which of the following is a legal way to declare and instantiate an array of 10 Strings?
- AString s = new String(10);
- BString[ ] s = new String[10];
- CString[10] s = new String;
- DString s = new String[10];
- EString[ ] s = new String;
33In Java, arrays are
- Ainterfaces
- Bprimitive data types if the type stored in the array is a primitive data type and objects if
the type stored in the array is an object - CStrings
- Dobjects
- Eprimitive data types
34What does the following code do? Assume list is an array of int values, temp is some previously
initialized int value, and c is an int initialized to 0.
for (int j = 0; j < list.length; j++)
if (list[j] < temp) c++;- AIt sorts the values in list to be in ascending order
- BIt counts the number of elements equal to the smallest value in list
- CIt finds the smallest value and stores it in temp
- DIt finds the largest value and stores it in temp
- EIt counts the number of elements in list that are less than temp
35Which of the following lists of numbers would accurately show the array after the first pass
through the Selection Sort algorithm?- A2, 4, 6, 8, 9, 12, 18
- B9, 4, 12, 2, 6, 8, 18
- C2, 4, 12, 9, 6, 8, 18
- D4, 9, 12, 2, 6, 8, 18
- E2, 4, 9, 12, 6, 8, 18
36Which of the following lists of numbers would accurately show the array after the second pass
of the Selection Sort algorithm?- A2, 4, 12, 9, 6, 8, 18
- B2, 4, 9, 6, 12, 8, 18
- C2, 4, 6, 8, 9, 12, 18
- D9, 4, 12, 2, 6, 8, 18
- E2, 4, 12, 6, 8, 9, 18
37Which of the following lists of numbers would accurately show the array after the fourth pass of
the Selection Sort algorithm?- A2, 4, 6, 8, 9, 12, 18
- B2, 4, 6, 9, 8, 12, 18
- C9, 4, 12, 2, 6, 8, 18
- D2, 4, 6, 8, 12, 9, 18
- E2, 4, 6, 9, 12, 8, 18
38Consider the array declaration and instantiation: int[ ] arr = new int[5]; Which of the following
is true about arr?- AIt stores 6 elements with legal indices between 0 and 5
- BIt stores 4 elements with legal indices between 1 and 4
- CIt stores 5 elements with legal indices between 1 and 5
- DIt stores 5 elements with legal indices between 0 and 4
- EIt stores 5 elements with legal indices between 0 and 5
39If int[ ] x = new int[15]; and the statement x[-1] = 0; is executed, then which of the following
Exceptions is thrown?- ANullPointException
- BIndexOutOfBoundsException
- CNegativeArraySizeException
- DArrayIndexOutOfBoundsException
- EArithmeticException
40The following code accomplishes which of the tasks written below? Assume list is an int array
that stores positive int values only
int foo = 0;
for (int j =0 ; j < list.length; j++)
if (list[j] > foo) foo = list[j];- AIt stores the largest value in list (the maximum) in foo
- BIt counts the number of elements in list that are less than foo
- CIt stores every value in list, one at a time, in foo, until the loop terminates
- DIt stores the smallest value in list (the minimum) in foo
- EIt counts the number of elements in list that are greater than foo
41The statement int[ ] list = {5, 10, 15, 20};
- Ainitializes list to have 4 int values
- Binitializes list to have 20 int values
- Ccauses a syntax error because it does not include "new int[4]" prior to the list of values
- Ddeclares list but does not initialize it
- Eadds 4 int values to array list
42Which of the following is true with respect to A1, A2 and A3?
- AA2 and A3 are both subclasses of A1
- BA3 is a subclass of A2 and A2 is a subclass of A1
- CA1 and A2 are both subclasses of A3
- DA1, A2 and A3 are all subclasses of the class A
- EA1 is a subclass of A2 and A2 is a subclass of A3
43Which of the following lists of instance data are accessible in class A2?
- Az, a, b
- Bx, z, a, b
- Ca, b
- Dx, y, z, a, b
- Ex, y, z, a
44Which of the following lists of instance data are accessible in A3?
- Ax, a, q
- Ba, b, q
- Ca, q
- Dx, y, z, a, b, q
- Ex, z, a, q
45Which of the following is true regarding the use of instance data y of class A1?
- AIt is accessible in A1, A2 and A3
- BIt is accessible only in A1
- CIt is accessible only in A3
- DIt is accessible in A1 and A2
- EIt is not accessible to any of the three classes
46The instruction super( ); does which of the following?
- Acalls the method super as defined in the current class'parent class
- Bcalls the constructor as defined in the current class'parent class
- Ccalls the method super as defined in the current class
- Dcalls the constructor as defined in the current class
- Ecalls the method super as defined in java.lang
47Inheritance through an extended (derived) class supports which of the following concepts?
- Acorrectness
- Binformation hiding
- Ccode reuse
- Dinterfaces
- Emodulary
48All classes in Java are directly or indirectly subclasses of the ________ class.
- AWrapper
- Bthis
- CString
- DObject
- EReference
49Abstract methods are used when defining
- Aarrays
- Bderived classes
- Cclasses that have no constructor
- Dinterface classes
- Eclasses that have no methods
50A variable declared to be of one class can later reference an extended class of that class. This
variable is known as- Aderivable
- Bpolymorphic
- Cprotected
- Dcloneable
- Enone of the above, a variable declared to be of one class can never reference any other
type of class, even an extended class
51In order to determine the type that a polymorphic variable refers to, the decision is made
- Aby the programmer at the time the program is written
- Bby the user at run time
- Cby the compiler at compile time
- Dby the Java run-time environment at run time
- Eby the operating system when the program is loaded into memory
52) The reference to getMoney( ) in assignment 1 is to the class
- ARetired
- BPerson
- CEmployee
- DStudent
- Enone of the above, this cannot be determined by examining the code
53The reference to getMoney( ) in assignment 2 is to the class
- ARetired
- BPerson
- CStudent
- DEmployee
- Enone of the above, this cannot be determined by examining the code
54The reference to getMoney( ) in assignment 3 is to the class
- APerson
- BRetired
- CEmployee
- DStudent
- Enone of the above, this cannot be determined by examining the code
55The relationship between a parent class and a child class is referred to as a(n) ________
relationship.- Ais-a
- Bhas-a
- Cinstance-of
- Dalias
- Ewas-a
Informações
- Descrição
- Quiz sobre Sem título, criado por Jon Ziemann em 14-12-2016.
- Autor
- Jon Ziemann
- Idioma
- English
- Visualizações
- 0
- Avaliação
- Ainda sem avaliações Avalie este quiz