Midterm Flashcards

1
Q

Which of these is not a primitive data type in Java?
a. int
b. String
c. float
d. Boolean

A

b. String

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

In System.out.println(“hello world”); System is a ________, println is a _________ and “hello world” is a _________
a. method, class, return-type
b. class, parameter, method
c. variable, method, parameter
d. class, method, parameter

A

d. Class, method, parameter

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

The formula for the volume of a sphere is

A

V= 4/3πr^3

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

In Java, the radius is saved as a double variable r. To calculate volume in Java we write
a. double v = 4Math.PIMath.pow(r, 3)/3;
b. double v = 4Math.PI()rrr/3;
c. double v = (4/3)Math.PIMath.pow(r, 3);
d. double v = (Math.PI()Math.pow(r, 3)4)/3;

A

a. double v = 4Math.PIMath.pow(r, 3)/3;

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

Scanner x = new Scanner(System.in); How would be input an integer and save it in variable count.
a. int count = input.nextInt;
b. int count = input.nextInt();
c. int count = x.nextInt;
d. int count = x.nextInt();

A

d. int count = x.nextInt();

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

The command to compile a file HelloWorld.java is

A

javac HelloWorld

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

To use the debugger in Eclipse, we create _____________ in the program where execution will pause and allow us to inspect variables.

A

Breakpoints

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

double x = 3.4567;
Which of these will print 3.46
a. System.out.print(x);
b. System.out.printf(“%.2f”, x);
c. System.out.printf(“%.3f”, x);
d. System.out.printf(“%f”, x);

A

b . System.out.printf(“%.2f”, x);

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

Git is a

A

Version Control System

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

double x = 31;
int y = 10;

Which of these will print Happy Halloween 10/31
a. System.out.printf(“Happy Halloween %d/%f”, y, x);
b. System.out.printf(“Happy Halloween %f/%d”, y, x);
c. System.out.printf(“Happy Halloween %d/%.0f”, y, x);
d. System.out.printf(“Happy Halloween %.0d/%f”, y, x);

A

c. System.out.printf(“Happy Halloween %d/%.0f”, y, x);

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

What is the Git command git innit used for?

A

Initializes a local git repository

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

What is the Git command git commit used for?

A

Takes everything thats in the index/staging area and commits it to the local repository

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

Who created Git?

A

Linus Torvalds and the Linux community

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

What is version control?

A

The tracking and managing of changes to software code

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

What does the Git command git add <file> used for?</file>

A

Adds the selected files to the staging area of the index, ready not to be commit

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

What is the Git command git status used for?

A

Checks what you have in the index/staging area, shows the differences between the working tree and the staging area

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

What is the Git command git push used for?

A

Pushes the local repository you have created and pushes it to a remote repository

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

What is the Git command git pull used for?

A

Pull the latest version from a remote repository

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

What is the Git command git clone used for?

A

Clones the repository into a new directory

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

The java compiler translates a .java file to generate a _____ file (what file extension for the created file?)

A

.class file

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

What command line command, reports the version of the Java compiler installed?

A

javac -version

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

What command line command, reports the version of the Java Runtime Environment installed?

A

java -version

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

When working in Eclipse, to edit and compile code you use the _____.

A

Editor or Workbench

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

What is the default file extension for UMLet diagrams?

A

.UXF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does this line of code do? int value1 = Integer.parseInt("42");
42 is a string, parseInt(String) converts it into an int
26
T/F - A string variable can hold digits such as account numbers and zip codes
True
27
Declaring a class does create actual objects
True
28
The data components of a class that belong to every instantiated object are the class's _____ variables
Instance
29
The access specifier in the declaration of instance variables should be _______
private
30
A method header consists of which of the following parts?
An access specifier, a return type, a method name, and a list of parameters
31
By using _________ you can use reasonable, easy-to-remember names for methods and concentrate on their purpose rather than on memorizing different method names
method overloading
32
What does static do in a class?
33
Which operator computes the remainder of an integer division?
%
34
a ________ evaluation is where each part of an expression is evaluated only as far as necessary to determine whether the entire expression is true or false
Short circuit
35
Area of a circle
πr^2
36
circumference of a circle
2πr
37
Volume of a rectangular prism
L*W*D
38
Volume of a cone
πr^2h/3 or (1/3)πr^2h
39
The command to compile a file HelloWorld.java is
javac HelloWorld.java
40
In flowcharts, input and output is always shown in ________
Parallelograms
41
Breaking large sequences of processing steps into smaller, reusable units in a computer program
Functional decomposition
42
Methods are also known as
Modules
43
Arguments are the actual inputted variable form of
parameters
44
Variables declared inside of a method body are part of that methods _____ and are not visible in other method bodies
local scope
45
a _____ is a blueprint for an ________
Class, Object
46
What is an object?
an object is an allocation of memory that contains properties and behaviours
47
Each object is also called is also called an _____ of the class
instance
48
A property is usually a
adjective
49
An object is typically a
noun
50
A (behaviour) method is typically a
verb
51
A UML Class Diagram looks like a rectangle or column with __ rows
3
52
A UML Class Diagram record the _____ and _____ for a class
Properties and behaviours
53
Instance variables are declared at the _____ level
Class
54
a java object property/attribute is implemented using 3 things:
Instance variable, accessor and mutator
55
2 Ways to identify a constructor
1. Same name as class 2. No return type
56
Primitive types: name the groups
4 Numeric no INT Byte Short Int Long 2 numeric with INT Float Double 1 Logic Bool 1 Numeric storing letters Char
57
Bits of memory Byte Short Int Long
8, 16, 32, 64
58
Should you use float or double for money calculations?
Neither
59
You cannot assign a ____ to a ____ or vice versa
Char, String
60
What does keyword static cause to happen when applied to a class-level variable?
The variables becomes part of the class and is shared by any instance
61
Why do we use static and final for class-level constants?
The value never changes, so to save memory we only keep one copy of value in memory (static)
62
A reference type variable contains a ______ not a ______
reference-value, object
63
x=5 y=10 x++ =? ++y= x++ + ++y =?
6, 10, 16 since x++ takes place after the equation
64
outputs Print ("test" + 1 + 2) Print(1 + 2 + "test")
test12 3test