CC 12 Midterms Flashcards

(25 cards)

1
Q

The Java if statement is the most simple decision-making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not.

True or False

A

True

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

If we want to do something else when if the condition is false, then we use the else statement.

True or False

A

True

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

Java while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean Condition.

True or False

A

True

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

The for statement consumes the initialization, condition and increment/decrement in one line thereby providing a shorter, easy to debug structure of looping.

True or False

A

True

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

do-while Loop checks for the condition before executing the statements or the loop body.

True or False

A

False

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

You may be writing a program where you want to evaluate multiple statements and execute code depending on which statement (if any) evaluates to true. That’s where the if statement comes in.

True or False

A

False

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

Nested if condition means an if statement within an if statement.

True or False

A

True

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

Normally, statements in a program are executed one after the other in the order in which they’re written. This process is called sequential execution.

True or False

A

True

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

In programming also face some situations where we want a certain block of code to be executed when some condition is fulfilled. This is repetition structures.

True or False

A

False

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

Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions while some condition evaluates to true.

True or False

A

False

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

It is accessible within the class in which it is defined and in its subclass?

A. protected
B. default
C. public
D. private

A

A. protected

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

Which of these is an incorrect array declaration?

A. int [] arr = new int[5]
B. int arr[] = new int[5]
C. int arr[] = int [5] new
D. int arr[]
arr = new int[5]

A

C. int arr[] = int [5] new

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

What is the first index of an array?

A. 3
B. 0
C. 2
D. 1

A

B. 0

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

What is the length of the following array: byte[] data = {12, 34, 9, 0, -62, 88};

A. 5
B. 6
C. 12
D. 1

A

B. 6

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

Must be specified by int or short value and not long.

A. method signature
B. return type
C. array size
D. modifier

A

C. array size

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

It is declared without using any modifier.

A. protected
B. default
C. public
D. private

17
Q

The direct superclass of an array type.

A. awt
B. swing
C. java.lang.Object
D. Object

A

C. java.lang.Object
D. Object

18
Q

A java method is defined once and invoked by writing its name without writing its code again.

A. inheritance
B. association
C. software issues
D. write once run anywhere

A

C. software issues
D. write once run anywhere

19
Q

A collection of statements that perform some specific task and return the result to the caller.

A. method
B. object
C. class
D. function

A

A. method
D. function

20
Q

Which of the following is FALSE about arrays on Java

A. A java array is always an object
B. Arrays in Java are always allocated on heap
C. Length of array can be changed after creation of array

A

C. Length of array can be changed after creation of array

21
Q

It is accessible in all classes in your application?

A. protected
B. default
C. public
D. private

22
Q

It is accessble only within the class in which it is defined?

A. protected
B. default
C. public
D. private

23
Q

Indicates the access type of a method.

A. access modifier
B. function
C. abstraction
D. modifier

A

A. access modifier
D. modifier

24
Q

You use a ____ following the closing brace of an array initialization list.

A. ;
B. ,
C. ;
D. .

25
The data type of the value returned by the method or void if does not return a value. A. String B. return type C. method type D. int
C. method type