Computer Programming Flashcards

1
Q

Sequential Structure

A

Executes a sequence of statements in order.

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

Control structure

A

Provides alternatives to sequential program and are used to alter the flow of execution

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

2 control structures

A

Selection structure
Repetition Structure

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

Selection structure

A

The program executes partical statements depending on the given condition. This alters the flow of program by making a selection or choice.

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

Repetition Structure

A

The program repeats statement a certain number of times, depending on the given condition. This alters the fliw of program execution by the repetition of one or more statements.

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

One way selection

A

If
If…else
switch statement

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

If and If…else statements

A

Used to create one-way, two-way and multiple selections

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

Switch Statement

A

is used to test a single variablr against a series of values.

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

The syntax for If statement

A

int score = 70;
if (score >= 60 ) {
System.out.printlb(“The student passed!”);
}

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

The Two-way selection

A

Used to choose between (2) alternatives. The if…else statement is used to implement two-way selections in Java.

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

The syntax for If…else statement

A

if ( score >=60)
{
System.out.println(“The student passed!”);
}
else
{
System.out.println(“The student failed!”);
}

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

Compound statements or Block statements

A

These are any kinfdof statements grouped together within curly braces.

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

Syntax for compound Statement

A

if (price => 500.00) {
discount = price * 0.10;
salePrice = price - discount;
System.out.println(“The discounted price is “ + salePrice);
}
else {
System.out.println(“No discount!”);
System.out.println(“The price is “ + price”);
}

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

Multiple Selections

A

When one control statement, either selection or repetition is located within another, it is said to be nested.

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

Nested if statement

A

allows a program to perform multiple selections

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

Syntax for nested if

A

if (score => 90){
System.out.println(“The grade is A”);
}
else if (score => 80) {
System.out.println(“The grade is B”);
}
else if (score => 70) {
System.out.println(“The grade is C”);
}
else {
System.out.println(“The grade is D”);
}

17
Q

Short Circuit Evaluation

A

Is a process which the computer evaluates a logical expression from left to right and stops as soon as the valur of the expression is determined.

18
Q

Switch Statement

A

Allows a single variable to be tested for equality against a list of values and, depending on its value, executes a certain block of statements.

19
Q

Rules for a switch case

A

The ff variables are allowed: int, byte, short, char, and String

20
Q

Syntax for Switch Statement

A

char grade = “A”;
switch (grade)
{
case ‘A’:
System.out.println(“Excellent!”);
break;
case ‘B’:
System.out.println(“Very Good!”);
break;
case ‘C’:
System.out.println(“Good!”);
break;
case ‘D’:
System.out.println(“Satisfactory”);
break;
case ‘E’:
System.out.println(“Failed”);
break;
}

21
Q

While

A

repeats a block of statements while a given condition evaluates to true

22
Q

Infinite loop

A

A loop that continues to execute endlessly

23
Q

Syntax for while loop

A

int num = 0;

while( num<= 10)
{
System.out.ptintln(num);
num++;
}

24
Q

For Loop

A

executes a sequence of atatements multiple times and abbreviates the code that manages the loop variable. It is used when a definite number of loop iterations is required.

25
Q

Syntax for For Loop

A

int num;
for (num =0; num<= 10; num++)
{
System.ouy.println(num);
}

26
Q

A do…while loop

A

Similar to a while loop, except that it executes the loop body first before evaluating the expression.

27
Q

Syntax for do…while loop

A

int num = 0;

do {
System.out.println(num);
num++;
} while (num <= 10);

28
Q

Break statement

A

Terminates the loop or switch and transfers the flow of the program to the statements following the loop or switch

29
Q

The continue statement

A

Causes the loop to skip the remainder of its body and immediately reevaluate its condition, and proceeds with the next iteration of the loop.

30
Q

Nested Control Structure

A

Are control statements that are placed withing another.

31
Q

String

A

a sequence of characters.