Quiz on Java Operators

Quiz
•
Computers
•
University
•
Medium
Jeevitha P
Used 102+ times
FREE Resource
7 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Find the output for the following.
public class IncDec
{
public static void main(String s[])
{
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
System.out.println("a = " + a);
System.out.print("b = " + b);
System.out.println("c = " + c);
System.out.print("d = " + d);
}
}
a = 2 b = 3 c = 4 d = 1
a = 2 b = 3 c = 4 d = 1
Program does not compile.
a = 1 b = 2 c = 4 d = 2
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following program?
public class DemoOnOperators
{
public static void main(String[] args)
{
int input = 7;
int output = ++input + ++input + ++input;
System.out.println(output);
}
}
-20
109
27
35
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following program?
public class DayMonthDemo
{
public static void main(String args[])
{
int num = 69;
int days = num % 30;
int month = num / 30;
System.out.println(month + " Month and " + days + " days");
}
}
3 Month and 9 days
2 Month and 9 days
0 Month and 69 days
0 Month and 29 days
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Choose the incorrect statement about the following expressions?
a=a+1; // Expression 1
a++; // Expression 2
a+=1; // Expression 3
++a; // Expression 4
All expressions give the same result
'Expression 2' is faster that 'Expression 3' which inturn is faster than 'Expression 1'
The value of 'a' after 'Expression 2' is different from 'Expression 4'
The value of 'a' after 'Expression 1' is same as 'Expression 3
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the program?
class Test
{
public static void main(String [] args)
{
int x=20;
String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
System.out.println(sup);
}
}
small
tiny
huge
Compilation fails
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the Java code snippet with Ternary operator?
String name = "java";
int marks = name == "java"?10:20;
System.out.println("Marks=" + marks);
marks=0
marks=10
marks=20
None of the above
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Find the output of the following snippet.
class Numbers
{
public static void main(String args[])
{
int a=20, b=10;
if((a<b)&&(b++ <25))
{
System.out.println("this is any language logic");
}
System.out.println(b);
}
}
10
12
11
Compilation Error
Similar Resources on Wayground
10 questions
Week 4: Recap Java Programming

Quiz
•
University
6 questions
Java array

Quiz
•
11th Grade - University
10 questions
Python Basics

Quiz
•
University
10 questions
Q8 - FundComp - Python Básico (En)

Quiz
•
University
10 questions
Third Year Placement Training Revision Test

Quiz
•
University
10 questions
Methods

Quiz
•
University
10 questions
Core Java Quiz

Quiz
•
University
10 questions
C Program Array and strings

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University