Looks like no one added any tags here yet for you.
The job of accessor and mutator methods are
to set and get the values of private instance variables
Encapsulation divides a class into which 2 of the following
implementation, and interface
Which of the following is not true when encapsulating a class definition
We should make helping methods, that are only to be called by other methods public
Which of the following are part of a class interface?
method signatures, and class javadoc comments
Which of the following are the defining principles of OOP programming
encapsulation, interface, polymorphism
A reference type is
a variable that holds references
What type should method that prints a string to the console be?
Cannot use == to compare 2 objects, must write a method that is .equals()
What happens if you compare 2 objects with (p1==p2)
nothing because both objects are not the same
Calling a method that returns a quantity
use anywhere a value can be used
Given a class called student that has a variable name, what would be the appropriate signature of the default constructor
public Student()
What is the purpose of defining and using a constructor
to instantiate an object, provide an object with initial values
What is the default constructor in java class
the constructor defined with no parameters, constructor that is provided to us by java when no other constructor defined
What is a static variable
a variable that belongs to the class itself and not the object
Int[] b = new int[10]
For (int i = 1 ; i <= b.length; i++)
b[i]=5*i;
what will the code do
the program will crash
Consider the following array-
Int[] a = new int[22];
What is the last index of a?
a.length-1 and 21
Given
Int[] numbers = new double[8];
numbers[2]=22.6;
What is the correct term for ‘numbers’?
array, array variable
The search algorithm that looks through each element in an array, in order, until a result is found is called
Sequential search
Which of the following are names for sorting algorithms
Selection sort, bogo sort
What are the purpose of accessor and mutator methods? When is it appropriate to use them? The act of adding these types of methods enables better what of our code?:
Set and get the values of the variables. We should always make them private. Better encapsulation of our code
What is a reference type? Are class objects reference types? Are primitive types such as int and double reference types?
Class objects are reference types. No
What is a foreach loop? How does it differ from a regular for loop? What structures, that we learned in class, can we use a foreach loop on? Suppose we had an object called Student. Create an array of students of size 10, use a foreach loop to iterate over that array. For each item in the array call the method writeOutput(); (you can assume that the method writeOutput() exists, is void, and is a method that belongs to the Student class()
it is a type of forloop, different because it doesn't have a variable condition or update statement, we used it in arrays
Int[] anArray = new int[15];
for(int i0; i< anArray.length; i++);
anArray[i] = 4*i;
For (int i=anArray.length-2; i>=0; i-=3)
System.out.print(anArray[i]+ “ “);
creating an array of 15 integers
going through whole array
0/0 4/1 8/2 12/3 16/4 20/5 24/6 28/7 32/8 36/9 40/10 44/11 48/12 52/13 56/14
Trace the steps that a selection sort takes as it sorts the following array into ascending order-
16 31 19 18 67 45 15
16 and 15 swap: 15 31 19 18 67 45 15
31 and 16 swap: 15 16 19 18 67 45 31
19 and 18 swap: 15 16 18 19 67 45 31
19 swaps with itself: 15 16 18 19 67 45 31
67 and 31 swap: 15 16 18 19 31 45 67
45 swaps with itself: 15 16 18 19 45 67