Logic Building in Java Part 1

Quiz
•
Professional Development, Computers
•
6th - 9th Grade
•
Hard
Mirdula R
Used 2+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
if (a){
System.out.println("A");
}
else if(a && b){
System.out.println("A && B");
}
else {
if(!b) {
System.out.println("notB");
}
else{
System.out.println("ELSE");
}
}
If a is true and b is true then output is A && B.
If a is true and b is false then output is notB.
If a is false and b is true then the output is ELSE.
If a is false and b is false then the output is ELSE.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the value of discount after the code block?
char gender='F';
byte discount;
if (gender='M') {
discount=10;
}
else{
discount=20;
}
10
Compilation Error
20
Runtime Error
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following program?
public class ShortTest {
public static void main(String[] args) {
boolean x = true;
boolean y = false;
if (x || y) {
System.out.println(true);
}
else {
System.out.println(false);
}
}
}
False
Runtime Error
True
Compilation Error
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the following:
long[][] stuff ;
Which of the following statements constructs an array with 5 rows of 7 columns each and assign its reference to stuff ?
stuff = new stuff[5][7] ;
stuff = long[5][7] ;
stuff = long[7][5] ;
stuff = new long[5][7] ;
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Examine the following:
double[][] values =
{ {1.2, 9.0, 3.2},
{9.2, 0.5, 1.5, -1.2},
{7.3, 7.9, 4.8} } ;
What is in values[3][0] ?
7.3
Error
7.9
9.2
6.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
From the following select the right way to invoke following method in the main method
class Example
{
static int add(inta,int b) {
return a+b;
}
}
add(20,30)
Example obj=new Example(); obj.add(10,20);
Static.add(10,20);
Example.add(10,20)
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
class Main{
public static void main(String []s)
{
float x=12.34F;
float y=13.25F;
float result=min(x,y);
System.out.println(result);
}
public static float min(float a,float b)
{
float minimun=a>b?b:a;
}
}
Compilation Error- function should have a return statement
12.34
Compilation Error - cannot invoke method without creating object
Runtime Error
Create a free account and access millions of resources
Similar Resources on Wayground
8 questions
Robotics Quiz

Quiz
•
1st - 12th Grade
8 questions
Python Basics Quiz

Quiz
•
6th Grade
12 questions
week 1 basic java coding language

Quiz
•
9th - 12th Grade
10 questions
Boolean Logic

Quiz
•
8th Grade
10 questions
Control Structures in Java

Quiz
•
8th Grade
15 questions
Python basics

Quiz
•
6th - 8th Grade
12 questions
Python Print Statement

Quiz
•
6th - 10th Grade
10 questions
Introduction to Arrays

Quiz
•
KG - University
Popular Resources on Wayground
15 questions
Hersheys' Travels Quiz (AM)

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
30 questions
Lufkin Road Middle School Student Handbook & Policies Assessment

Quiz
•
7th Grade
20 questions
Multiplication Facts

Quiz
•
3rd Grade
17 questions
MIXED Factoring Review

Quiz
•
KG - University
10 questions
Laws of Exponents

Quiz
•
9th Grade
10 questions
Characterization

Quiz
•
3rd - 7th Grade
10 questions
Multiply Fractions

Quiz
•
6th Grade
Discover more resources for Professional Development
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
15 questions
Hersheys' Travels Quiz (AM)

Quiz
•
6th - 8th Grade
30 questions
Lufkin Road Middle School Student Handbook & Policies Assessment

Quiz
•
7th Grade
17 questions
MIXED Factoring Review

Quiz
•
KG - University
10 questions
Laws of Exponents

Quiz
•
9th Grade
10 questions
Characterization

Quiz
•
3rd - 7th Grade
10 questions
Multiply Fractions

Quiz
•
6th Grade
20 questions
Guess The Cartoon!

Quiz
•
7th Grade