1.What will be the output of following Java code?
public class Main { public static void main(String[] args) { String str = "Hello"; str = "Bye"; System.out.println(str); } }
Java Program
Quiz
•
Computers
•
University
•
Hard
PUSHPALATHA C2114
Used 3+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
1.What will be the output of following Java code?
public class Main { public static void main(String[] args) { String str = "Hello"; str = "Bye"; System.out.println(str); } }
Hello
Bye
Error
All of these
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
2.public class Main { public static void main(String arg[]) { int i; for (i = 1; i <= 12; i += 2) { if (i == 8) { System.out.println(i); break; } } } }
1
No output
8
1357911
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
3.What will be the output of the following Java code?
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
a) 32
b) 33
c) 24
d) 25
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
4.What will be the output of the following Java program?
class variable_scope
{
public static void main(String args[])
{
int x;
x = 5;
{
int y = 6;
System.out.print(x + " " + y);
}
System.out.println(x + " " + y);
}
}
a) Compilation error
b) Runtime error
c) 5 6 5 6
d) 5 6 5
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
5.What will be the output of the following Java code snippet?
class abc
{
public static void main(String args[])
{
if(args.length>0)
System.out.println(args.length);
}
}
a) The snippet compiles and runs but does not print anything
b) The snippet compiles, runs and prints 0
c) The snippet compiles, runs and prints 1
d) The snippet does not compile
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
6.What will the following loop print?
for(int i = 0; i < 4; i++) { System.out.println(i); }
A.0 1 2
B.1 2 3
C.0 1 2 3
D.None
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
7.What is the output of this code?
int x = 1; while(x < 4) { System.out.println(x); x++; }
A.1 2 3
B.2 3 4
C.1 2 3 4
D.1
14 questions
Lets explore Java
Quiz
•
University
10 questions
Third Year Placement Training Revision Test
Quiz
•
University
15 questions
Java
Quiz
•
University
15 questions
Basic Java Quiz
Quiz
•
University
15 questions
Java Programming
Quiz
•
University
15 questions
Milking Minds 2 17-01-24
Quiz
•
University
10 questions
Java Quiz 1
Quiz
•
University
10 questions
Briefing Operator Java
Quiz
•
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