APT Quiz CS201

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Video A2 defines a method/function called concat(). What is the output of calling concat("howdy", 3)?

"howdyhowdyhowdy"

Consider the following code in Java: int x = 10; double y = 5; What is the output and what is the resulting type of y / x?

0.5, double

The automatic conversion from a primitive type to the corresponding object wrapper class(e.g. int -> Integer) in Java is called:

Autoboxing

Which of the following code snippets correctly creates an ArrayList that contains the same values as the array foo: int foo[] = new int[ ]{1,2,3}; a. ArrayList<Integer> list = new ArrayList<>(Arrays.asList(foo)); b. ArrayList<Integer> list = new ArrayList<>(); for(int element: foo){list.add(element);}

B

Which best categorizes the purpose of the Java break statement?

Control flow jumps or breaks out of the inner most loop in which break occurs

True or False: Arrays can be resized in Java.

False

True or False: In Java, String is a primitive data type.

False

True or False: Machines and algorithms are always objective and unbiased.

False

True or False: Method C is the most efficient algorithm out of the three.

False

How does Method B mentioned in video B 3 check for duplicates?

It compares a current element with the last element in 'ret' to check for duplicates.

In video A2, why is the builderConcat() method more efficient than the concat() method?

It uses StringBuilder to avoid copying the entire string each iteration

What is the sum of the numbers from 1 to N?

N*(N+1)/2

What kind of function characterizes the runtime of Method A mentioned in video B3?

Quadratic

A StringBuilder object is mutable, it can change, e.g., by calling the .append method

True

Refer to the code of Method A mentioned in video B 3. In which of the following cases is the boolean variable 'done' set to true?

When a duplicate has been found in 'ret'.

Recall the constructors for the Java class Person201 in video A3. Which of the following calls is/are correct for constructing a new Person201 object? a. Person201 p = new Person201(); b. Person201 q = new Person201("Joe", "30.3", "70.2", "foo"); c. Person201 r = new Person201("Tom", 56.4, 90.5, "foo");

a. and c.

Which of the following are true regarding Java ArrayLists? a. Java ArrayLists are resizable. b. Java ArrayLists can store primitive types. c. Java ArrayLists support random access.

a. and c.

What type does the String method .endsWith return?

boolean

What does the code example in A1 do?

count the number of unique words that appear in a file

What data type is 3.14?

double

Consider the following code in Java: String s = new String("CompSci201"); String t = new String("CompSci201"); Boolean x = (s == t); Boolean y = (s.equals(t)); What are the values of x and y respectively in every Java environment?

false, true

Which of the following syntaxes is correct for initializing an indexed for-loop?

for(init; boolean guard; update) {...}

What is the name of the method that retrieves a value from an ArrayList by its index?

get

What is the default value for object variables in java? (that is values in an array, for examples)

null

What kind of function characterizes the runtime of the Java concat() method in video A2?

quadratic

What is the content of the array foo after executing the following code? StringBuilder foo[ ] = new StringBuilder[3]; Arrays.fill(foo, new StringBuilder("du")); foo[0].append("ke");

{"duke","duke","duke"}


Ensembles d'études connexes

Psychological Disorders: Study Guide

View Set

Marketing 300 Concept Checks, Assignments, and Video Quizzes Chapter 8, Chapter 10

View Set

Vocabulary Workshop Level F unit 7

View Set

Government Unit 3: Test: United States Government

View Set