Intro Programming Flashcards

1
Q

The _____ statement gives control back to a method or constructor.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In a Java Do-While loop, the condition is evaluated at the _____ of the statement.

A

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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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()

A

this.action();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When is the Requirements Document finished?

A

Not until the customer agrees that it accurately describes everything he wants the program to do.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When would it be most appropriate to create a linked list in Java?

A

Storing elements in a dynamic array/

A linked list acts as a dynamic array because you can add, change, and remove elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which method retrieves but does not remove the element at the head of the deque?

A

The peek retrieves the head item but does not remove it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which data type is 1-bit in size?

A

Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

To move the contents of a variable declared as data type float into a variable declared as data type long requires the use of _____.

A

// The explicit type cast ‘(float)’ is required

float wayHome = 123456789;

long myBoat = (long) wayHome;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Actions are performed on an object by calling its _____.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In Java, length is associated with _____, and size is associated with _____.

A

Length is associated with an array. Size is associated with an ArrayList

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the difference between Array and ArrayList in Java?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is one major drawback of experimental analysis?

A

Implementation of programs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the shortest path problem?

A

The shortest path problem arises when are trying to find the shortest distance from one vertex to another vertex in a weighted graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To print a floating point number with a precision of 4 decimal places, the correct format string for System.out.printf would be:

A

The correct answer is ‘’%.4f’’ where .4 specifies the precision and f specifies it is a floating point number.

17
Q

Tool Tips are:

A

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.

18
Q

Which statement is NOT true about the static methods? In regards to overriding or overloading?

A

Static methods can be overidden

19
Q

_____ are passed to the main method as an array of String objects.

A

The space separated command line options (which occur AFTER the name of the file containing the Java program) are passed to the main method.

20
Q

How can the text in a label component be changed?

A

Values of label components can only be changed programatically at run time.

21
Q

What is NOT an asymptotic notation?

A

β is not a type of asymptotic notation.

22
Q

What type of sort is Quick Sort?

Big O?

A

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.

23
Q

Overriding vs Overloading in Java

A

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

24
Q

What is ‘Public Static Void Main’ in Java?

A

The means by creating a main method. Calls all others. Can’t return values. Accepts parameters

25
Q

Consider a situation where the minimum number of swap operation is required. Which sorting algorithm is best for this use-case?

A

Selection sort is the fastest

26
Q

Which of the following is a double in Java?

A

A double in Java can store a maximum of 16 digits after the decimal. So if there are more than 16 digits, Java will show an error. When f is appended to the decimal value the data is stored as a float, not a double.

27
Q

In Java, primitive data types are those that are _____, while non-primitive data types are _____.

A

defined by the language; not defined by the language

28
Q

Which Queue Interface method retrieves and removes the front element of a queue?

A

Poll

29
Q

Which method retrieves and removes the first element from a deque?

A

pollFirst

30
Q

The method of the parent class can be re-used and modified in a subclass inherited from the parent class. What is the term used to reference this behavior?

A

Overriding

31
Q

Vertices vs Edges in graphs

A

The objects are drawn as dots called vertices. A line (or curve) connects any two vertices representing objects that are related or adjacent; such a line is called an edge.

32
Q

Difference between List, Set and Map in Java

A

Set: Duplicates ignored.

Map/HashMap: A set a key value pairs. Basically an object. Isn’t ordered.

List/ArrayList: Array in java. ArrayList is dynamic. Array is is static length/size.

33
Q

How is the return value declared in a method?

A
34
Q

If all elements of an array are of the same type, the array is said to be _____.

A

Homogoneous

35
Q

What is the difference between an instance method and a static method?

A

Static methods should be accessed through class and not instance.