Ben Wharnsby
Test por , creado hace más de 1 año

Need to get 30/32 to pass!

34
0
0
Ben Wharnsby
Creado por Ben Wharnsby hace más de 9 años
Cerrar

Java quiz!

Pregunta 1 de 32

1

Definition: Describes an object in Java. Objects are created from these. Blueprints for a type of object. What am i?

Selecciona una de las siguientes respuestas posibles:

  • Primitive Type

  • Class

  • Object

  • Field

Explicación

Pregunta 2 de 32

1

An Object is a ...?

Selecciona una de las siguientes respuestas posibles:

  • Dynamic Entity, Created after constructor is invoked; collection of instance variables represent status.

  • Shape, relationship and model.

  • A value stored in associative memory.

  • Blueprint of an class.

Explicación

Pregunta 3 de 32

1

Difference between Primitive and Reference types?

Selecciona una de las siguientes respuestas posibles:

  • Primitives are stored as status of objects and Reference types are stored in memory as values.

  • Primitive types are stored in associative memory as a value; Reference types are stored in associative memory as an address of object state.

  • No differences, both stored in associative memory.

  • Both are dynamic entities.

Explicación

Pregunta 4 de 32

1

Difference between CLASS FIELD and INSTANCE VARIABLE?

Selecciona una de las siguientes respuestas posibles:

  • Fields are the types of data used in the class and an instance variable is used when a object is created allowing you to call the fields from a class.

  • Fields in class definition specify types of data that consistute to the status of the object. Instance variables are created when the class constructor is invoked; an instance variable is set to each field.

  • Class fields use the static modifier and are the types of data used in a class; instance variables allow you to reference data outside of a class.

  • Class fields must always use the public modifier and instance variables are assigned to each field in the class on invoked.

Explicación

Pregunta 5 de 32

1

A Constructor contains a return type and starts with CAPITAL letters? True or False.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 6 de 32

1

A method contains a Return type and by convention starts with lower case letters, addMoney(). True or False.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 7 de 32

1

Which of these represents a Constant Identifier?

Selecciona una de las siguientes respuestas posibles:

  • final boolean public normal_working_week = 37.5;

  • final boolean public NORMAL_WORKING_WEEK = 37.5;

  • final DOUBLE NORMAL_WORKING_WEEK = 37.5;

  • DOUBLE NORMAL_WORKING_WEEK = 37.5;

Explicación

Pregunta 8 de 32

1

What is a class variable?

Selecciona una de las siguientes respuestas posibles:

  • private static bookCount = 0;
    public Book {
    bookCount++;
    }

  • private final bookCount = 0;
    public Book {
    bookCount++;
    }

  • static private bookCount = 0;
    public Book {
    bookCount++;
    }

  • private int bookCount = 0;
    public Book {
    bookCount++;
    }

Explicación

Pregunta 9 de 32

1

What is the sequence to create a count for True and False values?

Selecciona una de las siguientes respuestas posibles:

  • Create a fixed sized array.
    Initialise 'n' elements with the int 0.
    For loop to iterate through array, checking if the value is True or False.
    Increment index 0, by 1 if true; index 1 by 1, if false.
    Return new array, [1, 2];

  • Initialise 'n' elements with the int 0.
    Create a fixed sized array.
    Increment index 0, by 1 if true; index 1 by 1, if false.
    For loop to iterate through array, checking if the value is True or False.
    Return new array, [1, 2];

  • Initialise 'n' elements with the int 0.
    Create a fixed sized array.
    Create a arraylist of type boolean.
    Increment index 0, by 1 if true; index 1 by 1, if false.
    For loop to iterate through array, checking if the value is True or False.
    Return new array, [1, 2];

  • Initialise 'n' elements with the int 0.
    Create a fixed sized array.
    Increment index 0, by 1 if true; index 1 by 1, if false.
    For loop to iterate through array, checking if the value is True or False.
    Return new array;

Explicación

Pregunta 10 de 32

1

Difference between an Array and an ArrayList?

Selecciona una de las siguientes respuestas posibles:

  • Array --> Fixed size, element can of only one type, but this type can be primitive/reference.
    ArrayList --> Variable size, elements can be reference types.

  • Array --> Variable size, element can be any type, but this type can be primitive/reference.
    ArrayList --> Variable size, elements can be reference types.

  • Array --> Variable size, element can be any type, but this type can be primitive/reference.
    ArrayList --> Fixed size, elements can be reference/primitive types.

  • Array --> Fixed size, element can of only one type, but this type can be primitive/reference.
    ArrayList --> Variable size, elements can be reference/primitive types.

Explicación

Pregunta 11 de 32

1

ArrayList<BankAccount> currentAccounts = new ArrayList<BankAccount>();
Is this Correct?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 12 de 32

1

Accessor methods --> Changes state of object by updating a value of instance variables.
Mutator methods --> Return information about the state of 'this' object. Doesn't change the value of a field.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 13 de 32

1

public boolean sendToService() {
return lastService + serviceInterval <= mileage;
}

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 14 de 32

1

What is recursion?

Selecciona una de las siguientes respuestas posibles:

  • Process of a method calling another method.

  • Process of a method calling itself.

  • Process of a class calling another method.

  • Process of a class calling itself.

Explicación

Pregunta 15 de 32

1

What are the 2 rules of Recursion?

Selecciona una de las siguientes respuestas posibles:

  • Must have at least 2 base classes + must ensure recursive calls eventually reach the base classes.

  • Must have at least 1 base class + must ensure recursive calls eventually reach the base class.

  • Must have at least 1 base class + must ensure recursive call at least one field in the class.

  • Must have at least 1 base class + must ensure recursive calls contain more than one argument.

Explicación

Pregunta 16 de 32

1

Tail Recursion --> Where the return is the last operation that happens in recursion. True? False?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 17 de 32

1

Recursive is better than Iterative, true or false?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 18 de 32

1

What is an algorithm?

Selecciona una de las siguientes respuestas posibles:

  • A method in Java which is used to count the number of elements in an arrayList.

  • Step by step process to solve a problem. Step by step instructions which termine and uses pseudo code.

  • Step by step process to solve a problem. Step by step instructions which termine on a method and uses real code and Java statements.

  • Step by step process to solve a linear search. Step by step instructions which termine on a method and uses real code, english and expressions.

Explicación

Pregunta 19 de 32

1

Worst-Case Complexity --> Maximum amount of computation used on an instance of a certain size. True or false?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 20 de 32

1

SelectionSort Algorithm:

a = [a1, a2, ..., an]

k = 1
for i from 1 to (n - 1) do:
find item, next that should be in position 'i' in the sorted array.
swap items a, and next.
next = an (array reference);
indexOfNext = i;

for j from i+1 to n do:
if aj < next then:
next = aj
indexOfNext = j
endif

Is the complexity N^2?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 21 de 32

1

Declare int indexOfNext and Comparable next;
For loop to iterate through array, but last element.
In for loop, assign next variable the current element and indexOfNext 'i'.
Still in for loop, do another for loop to iterate through all elements after current index, compare elements using compareTo() and assign next to a[j] and indexOfNext to 'j'; if next element is less than current element.
After 'j' for loop, a[indexOfNext] = a[i]; && a[i] = next; (Switch places).
Continue to loop!

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 22 de 32

1

Is this a correct statement?
Sorting.selectionSort(facebookFriends);

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 23 de 32

1

What is inheritance?

Selecciona una de las siguientes respuestas posibles:

  • Where a class implements another class or method. Features are inherited too.

  • Where the subclass can inherit features and methods from another base class.

  • Where the base class can inherit features and methods from another base class.

  • Where the subclass can inherit only methods from another base class.

Explicación

Pregunta 24 de 32

1

Public class House extends Building {
private int numBedrooms;
public void setNumBedrooms(int a) {
numBedrooms = a;
}
}

Is this Inheritance?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 25 de 32

1

What is the relationship between Building and House?

Selecciona una de las siguientes respuestas posibles:

  • Association

  • Encapulsation

  • Inheritance

  • Dynamic Binding

Explicación

Pregunta 26 de 32

1

If we create a class, Street; what is it's relation to House?

Selecciona una de las siguientes respuestas posibles:

  • Association.

  • Aggregation.

  • Encapulsation

  • Inheritance.

Explicación

Pregunta 27 de 32

1

public class Street {
...
}

Selecciona una de las siguientes respuestas posibles:

  • House[] houses;
    private String name;

    public Street(int b, String n) {
    name = n;
    houses = new House(b);
    }

  • ArrayList<House> houses;
    private String name;

    public Street(int b, String n) {
    name = n;
    houses = new House(b);
    }

  • ArrayList<House> houses;
    private String name;

    public Street(int b, String n) {
    name = n;
    houses = new House(b);
    name = b;
    }

  • House[] houses;
    private Int name;

    public Street(int b, String n) {
    name = n;
    houses = new House(b);
    }

Explicación

Pregunta 28 de 32

1

Method Overriding?
Subclass changes it's behaviour of the baseclass, keeping the same method signature.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 29 de 32

1

Polymorphism
A variable to hold just one reference to different types of classes.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 30 de 32

1

Dynamic Binding

Operation to apply polymorphic variable is determined at runtime.
Depending on which class is currently assigned to a value (Account s), depends on which method is called.

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 31 de 32

1

What is an interface?

Selecciona una de las siguientes respuestas posibles:

  • Collection of methods and objects.

  • Collection of abstract methods.

  • Collection of methods.

  • Collection of fields.

Explicación

Pregunta 32 de 32

1

Does a class that implement an interface have to implement all methods?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación