Lecture: Quiz 1 Flashcards

Lessons tackled in Lecture of BIT 112: Fundamentals of Programming. About statements

1
Q

What is the purpose of the if-else-if statement in Java?

A

To handle multiple complex selections

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

What does the if-statement check?

A

If a Boolean expression is true

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

Which statement correctly initializes a BufferedReader?

A

BufferedReader dataln = new BufferedReader(new InputStreamReader(System.in));

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

What does the else-if statement allow you to do?

A

Chain multiple conditions

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

What must be included when using BufferedReader to handle input?

A

try-catch block

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

Which class is used to read character input from a byte stream in Java?

A

InputStreamReader

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

Which of the following is a valid way to declare a variable in Java?

A

int number1;

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

Which method is used to read a line of text from the keyboard using BufferedReader?

A

readLine()

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

Which of the following statements is true about the if statement?

A

It can evaluate expressions.

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

What will be the output of the following code if score is 75:

if (score >= 70)
System.out.println(“Good”);
else
System.out.println(“Needs Improvement);?

A

Good

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

What is the purpose of the try-catch block in Java?

A

To handle exceptions

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

Which of the following is NOT a decision control structure?

A

For loop

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

What is the output of the following code if x is 10:

if (x < 5)
System.out.println(“Low”);
else
System.out.println(“High”); ?

A

High

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

What is the output of the following code if grade is 50:

if (grade > 60)
System.out.println(“Passed”);
else
System.out.prinln(“Failed”); ?

A

Failed

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

What is the purpose of JOptionPane in Java?

A

To pop up dialog boxes

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