Quiz
Final Quiz - 1409
Erstelle ein kostenloses Konto, um dieses Quiz zu beenden
Speichere deinen Fortschritt und sieh dir dein Endergebnis an.
oder mit deiner E-Mail registrieren
Schon ein Konto? Anmelden
Fragen in diesem Quiz (67)
1Which of these best describes a Java class?
- AThe place I go every Thursday night.
- BA blue print from which Objects are created.
- CA runtime representation of data and behaviour.
- DA type of data used in Object Oriented Programming.
2What is an Object in OO Programming?
- AAn instance of a class.
- BA blueprint of a reference type.
- CA kind of primitive data type type to hold undefined data.
- DA abstract tool used to model a class design.
3Choose the reference type from the list below.
- Achar
- Bboolean
- Cint
- DString
4Which of these is a valid boolean?
- Ano
- B"false"
- Cfalse
- Dyes
5Which of the following is the correct way to declare an instance variable which holds a "null" value?
- ADog name = "Darby";
- BString gender;
- Cint dogsAge;
- Dpublic class Dog{...}
6Select the best way to name a class that holds data for a person.
- APERSON
- BPerson
- Cperson
- Dobject
7Constructors are used to
- ANone of these.
- Bensure valid data types are declared for instance variables
- Cconstruct proper return types are declared for methods
- Densure valid default values are set for instance variables
8What is this signature inferring?
public void bark()- AThis method can be called internally only.
- BThis method is actually a constructor.
- CThis method can be called externally
- DThis method will return a value called void.
9Assuming age has a value of 10, what is the output of the following?
if(age > 10 && age < 100)
{
System.out.println("foo");
}
else
{
System.out.println("bar");
}- Ano output
- Bfoo
- Cfoo
bar - Dbar
10Assuming age has a value of 10, what is the output of the following?
if(age > 10 || age < 0)
{
System.out.println("foo");
}
else
{
System.out.println("bar");
}- Abar
- Bno output
- Cfoo
- Dfoo
bar
11Accessor methods normally return a void data type.
- ARichtig
- BFalsch
12Constructors must be declared with a return type.
- ARichtig
- BFalsch
13Accessor and mutator methods are normally declared as public.
- ARichtig
- BFalsch
14Accessor methods take a parameter, while mutator methods do not.
- ARichtig
- BFalsch
15Given the instance variable below, choose the correct constructor that would be used to assign an input value to it.
private String dogsName;- Apublic Dog(String name){ dogsName = "Darby"; }
- Bpublic Dog(){ dogsName = "Darby"; }
- Cpublic Dog(String name){ name = dogsName; }
- Dpublic Dog(String name){ dogsName = name; }
16Choose the correct mutator signature for the instance variable below.
private boolean neutered;- Apublic boolean setNeutered(String isNeutered)
- Bpublic String setNeutered(boolean isNeutered)
- Cpublic void getNeutered(boolean isNeutered)
- Dpublic void setNeutered(boolean isNeutered)
17What is displayed to the console when the following code is processed?
System.out.println("joe" + " " + "malcolm" + " parker is " + "60" + 2 + 4);
System.out.println(" years old");
System.out.println(" already");- Ajoe malcolm parker is 6024 years old already
- Bjoe malcolm parker is 6024
years old
already - Cjoe malcolm parker is 606
years old
already - Djoe malcolm parker is 6024 years old
already
18What is displayed in the console when the following code is processed?
System.out.println(100 + 70 + "john doe" + 100 + 70);- Ano output because of syntax error
- B170john doe10070
- C170 john doe 100 70
- D170 john doe100 70
19What will be the console output when the code below is processed?
System.out.println( 5 + 4 + 3 );- Ano output because of syntax error
- B543
- C5 4 3
- D12
20Logical operators are commonly used to do this.
- Aconcatenation
- Bencapsulation
- Cvalidation
- Dinstantiation
21What is wrong with this method?
public boolean isAGoodPerson() {
if(helpsOthers == true){
return true;
}
}- Ashould return a String
- Bno return statement for a false result
- CNothing
- Dshould read if(helpsOthers = true)
22What is false about local variables?
- AThey are only accessible from within the method they are declared.
- BThey can be used to hold a value passed to the method as an argument.
- CThey can be of any data or reference type.
- DThey are accessible by other methods in the same class.
23Which scope modifier do we use for local variables?
- Apublic
- Bany of these
- Cprivate
- Dnone
24What is wrong with the method below?
public String display(String value, int number) {
String output = value + " " + number;
}- AThis should be a "set" method.
- BMissing the return statement.
- CYou can't add Strings and ints.
- DThere is nothing wrong.
25Select the false statement below.
- AA method with a return statement must also have the correct return type in it's signature.
- BMethods always have a return value.
- CStatic methods are shared among all instances of a class.
- DIf a method can not find a variable in it's local scope, it will next look at the class scope.
26What will be the final value of the boolean?
boolean x = false;
if(x != true)
{
x = true;
}- Afalse
- B-1
- Ctrue
- D0
27What will be the final value of the boolean?
int y = 6;
boolean x = false;
if((y >= 6) && (y == 0))
{
x = true;
}- Afalse
- Btrue
- C6
- D0
28When a property is declared with the keyword static, then it becomes an instance variable.
- ARichtig
- BFalsch
29A variable declared inside one method cannot be read from inside another method.
- ARichtig
- BFalsch
30Constants can be changed with a public mutator method.
- ARichtig
- BFalsch
31The class that contains the code below will compile?
public static int age = 10;
public void setAge( int number ){
age = number;
}- ARichtig
- BFalsch
32What will be printed?
int a = 4;
int b = 4;
System.out.println(a++ + b++);- A8
- B9
- C10
- DInvalid syntax.
33Which of the following is the correct way to declare a symbolic constant?
- Apublic static numberOfDays = 7;
- Bpublic static final int daysOfTheWeek = 7;
- CAll of these are correct.
- Dpublic static final int DAYS_OF_THE_WEEK = 7;
34If I want a variable to be a class variable rather than an instance variable I would do this.
- ADeclare the variable as public scope
- BDeclare the variable as final.
- CDeclare the variable as private scope.
- DDeclare the variable as static.
35What will be printed?
int a = 4;
int b = 4;
int c = a++ + b++;
System.out.println(c)- A8
- B9
- C10
- DInvalid syntax.
36What will be the final value of x?
int x = 6;
x++;
x = x + x;- A6
- B13
- C14
- D7
37The class that contains this code will compile.
private final int MONTHS = 12;
public void setMonths( int number ){
MONTHS = number;
}- ARichtig
- BFalsch
38What will be printed?
int a = 4;
int b = 4;
System.out.println(a-- + ++b);- A9
- B10
- CInvalid syntax.
- D8
39What will the output value of number be?
int number = 10;
System.out.println(number++);- A20
- Bno output because of programming error.
- C10
- D11
40In regards to Overloading, select the true statement.
- AThe difference in signatures will allow overloading in constructors only.
- BThe difference in signature will allow overloading for constructors or methods.
- CA constructor can only be overloaded twice.
- Dpublic Car (int year, int price)
is a different signature than
public Car (int price, int year)
41Which word refers to the ability to ignore details to focus on the higher level problem?
- AAbstraction
- BDefinition
- CAssociation
- DInstantiation
42What is Modularization?
- Acombining well defined parts into a single unit
- Bdividing the whole into well defined parts
- Cthe process of defining a class definition
- Danother word for instantiating an Object
43When a reference has no value it is said to be this.
- Anull
- Bdefault
- Cempty
- Ddead
44This happens when methods have the same name but different parameter lists.
- AOverloading
- BConfusion
- CAssociation
- DModularization
45Within a method, the difference between returning a value and printing a value is
- Awhen you return a value, the caller has control over the value
- BYou are unable to print values in a method.
- Cwhen you print a value, the caller has control over the value.
- Dboth are the same thing
46Which is used to create an Object?
- Anew
- B==
- Cnull
- D=
47When an Object's method is called from inside a different class it is called an _______________ call.
- Aexternal
- Babstract
- Cinherited
- Dinternal
48The calculation 17%3 returns this value.
- A3
- B2
- Cnull
- D1
49What is an Object's identity?
- Athe Object name
- Bthe Object variable name
- Cthe Object type
- Dthe Object address
50Select the true statement.
input == "bye"- Ainput will contain the String "bye"
- Binput cannot be a String
- Cnone of these options are true
- D"bye" was successfully assigned to input
51What does it mean when one Object is equal to another.
- AThe Object addresses are the same.
- BThe values the Objects hold are the same.
- CThe test object_1.equals(object_2) returns a positive int value.
- DAll of these options are true
52What does the value of "some_condition" in the code segment below have to equal for the code in the loop to be processed?
while( some_condition ) {
//code to be processed
...
}- Afalse
- Bboolean
- Cnull
- Dtrue
53What will be the value of index when we break out of the loop below?
int index = 0;
int size = 9;
while(index = size) {
System.out.println(index);
index++;
}- A9
- BInvalid syntax.
- C10
- Dfalse
54What will the value of counter be when we break out of the loop below?
int counter = 1;
while(counter <= 10) {
System.out.println(counter);
counter++;
}- Afalse
- B10
- CThe loop won't work properly.
- D11
55Given the following code, what is the output?
int numbers[] = new int[5];
numbers[0] = 1;
numbers[1] = 2;
numbers[2] = 3;
numbers[3] = 4;
numbers[4] = 5;
numbers[5] = 6;
System.out.println(numbers[5]);- Awon't compile
- Bwon't run
- C5
- D6
56When I want an Object to reference itself what keyword do I implement?
- Anull
- Bnew
- Cthis
- Dreturn
57When a reference is declared but the Object has yet to be created, what is the value of the reference?
- Anull
- Bdefault
- Cempty
- Ddead
58To use an ArrayList I must do this.
- Aimport java.util.ArrayList
- Bimport java.ArrayList
- Cimport java.lang.ArrayList
- Dimport java.lang.ArrayList<type>
59Programming language support, like Java utility classes, are held in these.
- Alibraries
- Bfolders
- CAPI's
- Dprojects
60This refers to the number of elements a Collection can hold.
- Alimit
- Bquantity
- Clength
- Dsize
61Which is the best way to declare an ArrayList?
- AArrayList<type> list = new ArrayList<type>();
- BArrayList list = new ArrayList();
- CArrayList[] list = new ArrayList[size];
- DArrayList list = new ArrayList(size);
62Select the true statement about ArrayLists.
- AThe number of elements they can contain is fixed.
- BElements can be of generic types.
- CThey are memory efficient.
- DThey can store multiple Object reference types.
63When would it be appropriate to use an ArrayList?
- AWhen we want to collect an unknown number of primitive values.
- BWhen we are not sure how many references of a type we will be creating.
- CWhen the number of elements will always be the same.
- DAll of these are good reasons to use an ArrayList.
64Consider the code segment below where "stringList" is a reference to an ArrayList , and select the correct option.
for(String value : stringList) {
System.out.println("1. " + value);
}- AWhatever data type the ArrayList holds the toString() implementation of that type will be called.
- BThe ArrayList must contain String references only.
- CIt will work regardless of what type the ArrayList holds, because the output statement will call the toString() implementation of any reference type.
- DIt won't work since Strings are primitive data types and ArrayLists can hold only reference types.
65The number of iterations a "for-each" loop will iterate over an ArrayList is determined by this.
- Auntil the computer blows up
- BThe ArrayList size
- Cthe ArrayList capacity
- Duntil the capacity equals the size
66Select the false statement below.
- AThe for-each loop will only work for Collections that are organized sequentially.
- BWe can read an ArrayList in reverse order using a for-each loop.
- CTo use the for-each loop we should use Generics to specify the type of reference the ArrayList holds.
- DThe for-each loop can be used to read an entire ArrayList of Object references.
67Where "team" is an ArrayList of HockeyPlayer references, what will the following code segment do?
for( HockeyPlayer player : team ) {
System.out.println(player.getPlayerName());
}- ADisplay the ArrayList index value for element.
- BDisplay the name of each HockeyPlayer.
- CInvalid syntax.
- DDisplay the name of the ArrayList.
Informationen
- Beschreibung
- Computer Science Quiz am Final Quiz - 1409, erstellt von Albert Kozak am 03/04/2019.
- Autor
- Albert Kozak
- Sprache
- English
- Aufrufe
- 11
- Schlagwörter
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz