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
Q

What does this line of code do?
int value1 = Integer.parseInt(“42”);

A

42 is a string, parseInt(String) converts it into an int

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

T/F - A string variable can hold digits such as account numbers and zip codes

A

True

27
Q

Declaring a class does create actual objects

A

True

28
Q

The data components of a class that belong to every instantiated object are the class’s _____ variables

A

Instance

29
Q

The access specifier in the declaration of instance variables should be _______

A

private

30
Q

A method header consists of which of the following parts?

A

An access specifier, a return type, a method name, and a list of parameters

31
Q

By using _________ you can use reasonable, easy-to-remember names for methods and concentrate on their purpose rather than on memorizing different method names

A

method overloading

32
Q

What does static do in a class?

A
33
Q

Which operator computes the remainder of an integer division?

A

%

34
Q

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

A

Short circuit

35
Q

Area of a circle

A

πr^2

36
Q

circumference of a circle

A

2πr

37
Q

Volume of a rectangular prism

A

LWD

38
Q

Volume of a cone

A

πr^2h/3 or (1/3)πr^2h

39
Q

The command to compile a file HelloWorld.java is

A

javac HelloWorld.java

40
Q

In flowcharts, input and output is always shown in ________

A

Parallelograms

41
Q

Breaking large sequences of processing steps into smaller, reusable units in a computer program

A

Functional decomposition

42
Q

Methods are also known as

A

Modules

43
Q

Arguments are the actual inputted variable form of

A

parameters

44
Q

Variables declared inside of a method body are part of that methods _____ and are not visible in other method bodies

A

local scope

45
Q

a _____ is a blueprint for an ________

A

Class, Object

46
Q

What is an object?

A

an object is an allocation of memory that contains properties and behaviours

47
Q

Each object is also called is also called an _____ of the class

A

instance

48
Q

A property is usually a

A

adjective

49
Q

An object is typically a

A

noun

50
Q

A (behaviour) method is typically a

A

verb

51
Q

A UML Class Diagram looks like a rectangle or column with __ rows

A

3

52
Q

A UML Class Diagram record the _____ and _____ for a class

A

Properties and behaviours

53
Q

Instance variables are declared at the _____ level

A

Class

54
Q

a java object property/attribute is implemented using 3 things:

A

Instance variable, accessor and mutator

55
Q

2 Ways to identify a constructor

A
  1. Same name as class
  2. No return type
56
Q

Primitive types: name the groups

A

4 Numeric no INT
Byte Short Int Long
2 numeric with INT
Float Double
1 Logic
Bool
1 Numeric storing letters
Char

57
Q

Bits of memory
Byte
Short
Int
Long

A

8, 16, 32, 64

58
Q

Should you use float or double for money calculations?

A

Neither

59
Q

You cannot assign a ____ to a ____ or vice versa

A

Char, String

60
Q

What does keyword static cause to happen when applied to a class-level variable?

A

The variables becomes part of the class and is shared by any instance

61
Q

Why do we use static and final for class-level constants?

A

The value never changes, so to save memory we only keep one copy of value in memory (static)

62
Q

A reference type variable contains a ______ not a ______

A

reference-value, object

63
Q

x=5
y=10
x++ =?
++y=
x++ + ++y =?

A

6, 10, 16 since x++ takes place after the equation

64
Q

outputs
Print (“test” + 1 + 2)
Print(1 + 2 + “test”)

A

test12
3test