1.What would be the output of the following code snippet if variable a=10?
if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
{
System.out.println("2 ");
}
}
System.out.println("3 ");
flow control
Quiz
•
Computers
•
University
•
Hard
PUSHPALATHA C2114
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
1.What would be the output of the following code snippet if variable a=10?
if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
{
System.out.println("2 ");
}
}
System.out.println("3 ");
a) 1 2
b) 2 3
c) 1 3
d) 3
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
2. What is true about a break?
a) Break stops the execution of entire program
b) Break halts the execution and forces the control out of the loop
c) Break forces the control out of the loop and starts the execution of next iteration
d) Break halts the execution of the loop for certain time frame
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
3.What is true about do statement?
a) do statement executes the code of a loop at least once
b) do statement does not get execute if condition is not matched in the first iteration
c) do statement checks the condition at the beginning of the loop
d) do statement executes the code more than once always
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
4.What is the valid data type for variable “a” to print “Hello World”?
switch(a)
{
System.out.println("Hello World");
}
a) int and float
b) byte and short
c) char and long
d) byte and char
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
5.Which of these are selection statements in Java?
a) if()
b) for()
c) continue
d) break
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
6.Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
a) do-while
b) while
c) for
d) none of the mentioned
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
7.What will be the output of the following Java program?
class selection_statements
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}
a) 1
b) 2
c) 3
d) 4
15 questions
Java Programming
Quiz
•
University
8 questions
Java operators
Quiz
•
University
10 questions
Java quiz 1
Quiz
•
University
15 questions
Java Quiz based on array
Quiz
•
University
10 questions
Java Programming Basics
Quiz
•
University
15 questions
C++ Quiz-1
Quiz
•
University
15 questions
Trắc nghiệm kiến thức Java Core - Phần I
Quiz
•
University
15 questions
Soal Java
Quiz
•
11th Grade - University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade