Unit 1 Flashcards

(28 cards)

1
Q

What type of code is typed into a .java file?

a. class file
b. source file
c. java file

A

b. source code

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

Source code is compiled to produce what type of file for each class you define

a. .class file
b. .java file
c. .java.lang file

A

a. .class file

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

One .class file must contain a method called _____ (which accepts only an array of Strings) which the Java Virtual Machine will call to start the program running

a. .class file
b. .java.lang file
c. main file

A

c. main file

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

what is the correct term for the following

class Person

what is Person here?

A

identifier

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

what is the correct term for the following

public static void main(String[] args)

what is static void here?

A

keywords

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

a java program
is a collection of 1 or more __________?

a. methods
b. attributes
c. classes

A

c. classes

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

1 java class MUST contain the method called __________

A

main method

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

_________ never returns a value

a. void
b. static
c. return

A

a void

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

_______ keyword is used only one per class, not one per object

a. void
b. int
c. static
d. boolean

A

c. static

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

1 byte = ________ bits

A

8

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

bits consists of

a. 1s and 1s
b. 0s and 1s
c. 0s and 0s

A

b. 0s and 1s

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

A ________ value is a value which we directly type into the code

a. literal
b. direct
c. constant

A

a. literal

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

‘\n ‘ precedented backslash is used for

a. previous line
b. new line
c. next string

A

b. new line

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

what is the example of char

a. ‘\r’
b. 1
c. name
d. 1.0

A

a. ‘\r’

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

what is this?
int myInteger = 5;

a. assignment
b. instantiation
c. declaration

A

c. declaration

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

Words and sentences that are stored in memory can be considered as a sequence of individual characters in __________ class

a. integer class
b. main method
c. String class

A

c. String class

17
Q

pay *= 1.2 is equivalent to

a. pay * 1.2
b. pay * = pay * 1.2
c. pay = pay * 1.2

A

c. pay = pay * 1.2

18
Q

total = total + sub * sub;
is equivalent to

a. total +=sub * sub;
b. total = +sub * sub;
c. total = sub + sub * sub;

A

a. total +=sub * sub;

19
Q

total– is equivalent to

a. total = total - 1
b. total -1

A

a. total = total - 1

20
Q

a = 6;
b = ++a - 1;

then b =

a. b = 6
b. b = 7
c. b = 5

21
Q

x + 3 <= y * 5

a. expression
b. variable

A

a. expression

22
Q

int a= 1, b= 2, c = 3, d ;

if ((a<b) || (c < a))
d = 10;
else
d = 20;

23
Q

for (ctr = 1; ctr < 10; ctr ++){
System.out.print(ctr * ctr);
System.out.print(“ ”);

a. 1 4 9 16 25 36 49 64 81
b. 1 3 8 15 24 36 47 62 80
c. 1 4 9 16 25 35 48 64 81

A

a. 1 4 9 16 25 36 49 64 81

24
Q

which loop to use when the number of iterations is known

a. for loop
b. do while loop
c. case statement

25
which loop runs at least once
do while loop
26
int number = 1; marks[number] = 38; what index number will store 38? a. marks [0] b. marks[number] c. marks[1]
c. marks[1]
27
public static void introduction() { String name = "Thomas"; int age = 40; System.out.println("My name is " + name + " and I am " + age + " years old."); } what is the name of the method?
introduction()
28