Intro Programming Flashcards
(35 cards)
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.
To print a floating point number with a precision of 4 decimal places, the correct format string for System.out.printf would be:
The correct answer is ‘’%.4f’’ where .4 specifies the precision and f specifies it is a floating point number.
Tool Tips are:
Tooltip, unlike JTextField and JButton, is not a class in Java. It is, rather, a functionality that is available to GUI components and is implemented as a method.
Which statement is NOT true about the static methods? In regards to overriding or overloading?
Static methods can be overidden
_____ are passed to the main method as an array of String objects.
The space separated command line options (which occur AFTER the name of the file containing the Java program) are passed to the main method.
How can the text in a label component be changed?
Values of label components can only be changed programatically at run time.
What is NOT an asymptotic notation?
β is not a type of asymptotic notation.
What type of sort is Quick Sort?
Big O?
There are several different types of sorting algorithms: insertion, selection, exchange, and merge. The Quick Sort is a type of exchange sort.
It has a Big O rating of O(n log n) for average performance and an O(n^2) worst case performance.
Overriding vs Overloading in Java
Overriding Occurs between superclass and subclass. Have the same signature (name and method arguments). On error, the effect will be visible at runtime
Overloading Occurs between the methods in the same class. Have the same name, but the parameters are different. On error, it can be caught at compile time
What is ‘Public Static Void Main’ in Java?
The means by creating a main method. Calls all others. Can’t return values. Accepts parameters