Intro Programming Flashcards
The _____ statement gives control back to a method or constructor.
In a Java Do-While loop, the condition is evaluated at the _____ of the statement.
The condition is evaluated at the end, unlike other loops. That way, we get one more run through the sprinkler before checking if our time is up!
Given a class Example with static method called action with no parameters, which of the following is never a correct call for the static method ?
1) this.action()
2) action()
3) Example ex = new Example()
ex.action()
4) Example.action()
this.action();
When is the Requirements Document finished?
Not until the customer agrees that it accurately describes everything he wants the program to do.
When would it be most appropriate to create a linked list in Java?
Storing elements in a dynamic array/
A linked list acts as a dynamic array because you can add, change, and remove elements.
Which method retrieves but does not remove the element at the head of the deque?
The peek retrieves the head item but does not remove it.
Which data type is 1-bit in size?
Boolean
To move the contents of a variable declared as data type float into a variable declared as data type long requires the use of _____.
// The explicit type cast ‘(float)’ is required
float wayHome = 123456789;
long myBoat = (long) wayHome;
Actions are performed on an object by calling its _____.
A method is a unit of programming which accepts parameters passed in and performs some action (possibly utilizing and/or modifying the object’s internal state variables). A method can optionally return a value to the caller.
In Java, length is associated with _____, and size is associated with _____.
Length is associated with an array. Size is associated with an ArrayList
What is the difference between Array and ArrayList in Java?
ArrayList belongs to Collection framework. ArrayList is dynamic vs Array which is static in size. ArrayList has methods you use to get values like .add(i) and .get(i)
What is one major drawback of experimental analysis?
Implementation of programs
If we declare a two-dimensional array of size 5 by 5 and the data type stored is 4 bytes long, how much memory will be allocated?
The correct answer is ‘192 bytes’. We have the array header of 12 bytes plus 5 elements times 4 bytes which equals 32 and since it is a multiple of 8 we do not need padding. Then each element has an array of its own, also of size 5, so we have 5 * 32 bytes which equals 160. Lastly we add 32 to 160 and we have 192 bytes.
What is the shortest path problem?
The shortest path problem arises when are trying to find the shortest distance from one vertex to another vertex in a weighted graph
When it comes to Java, a(n) _____ is used to fill up the rest of the container with content and can be called its extension.
A component can be defined as a thing or element that is a part of something much bigger. The GUI component in Java is secondary to that of the container element.