Predict the output:
class Test {
protected int x=10, y=10;
}
class Main {
public static void main(String args[]) {
Test t = new Test();
System.out.println(t.x + " " + t.y);
}
}
Programming in Java - Output Prediction
Quiz
•
Computers
•
University
•
Medium
Lakshmi Anand
Used 4+ times
FREE Resource
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Predict the output:
class Test {
protected int x=10, y=10;
}
class Main {
public static void main(String args[]) {
Test t = new Test();
System.out.println(t.x + " " + t.y);
}
}
Garbage Value
0 0
10 10
5 5
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Predict the output:
class Test {
private static int x;
public static void main(String args[]) {
System.out.println(fun());
}
static int fun() {
return ++x;
}
}
1
Error
0
Garbage Value
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Predict the output:
class Base {
public void Print()
{
System.out.println("Base");
}
}
class Derived extends Base {
public void Print()
{
System.out.println("Derived");
}
}
class Main {
public static void DoPrint(Base o)
{
o.Print();
}
public static void main(String[] args)
{
Base x = new Base();
Base y = new Derived();
Derived z = new Derived();
DoPrint(x);
DoPrint(y);
DoPrint(z);
}
}
Base
Derived
Base
Base
Derived
Derived
Derived
Base
Derived
Derived
Derived
Base
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Predict the output:
class Test {
int x = 10;
public static void main(String[] args)
{
Test t = new Test();
System.out.println(t.x);
}
}
1
0
10
11
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Predict the output:
class Base {
protected void foo() {}
}
class Derived extends Base {
void foo() {}
}
public class Main {
public static void main(String args[]) {
Derived d = new Derived();
d.foo();
}
}
Runtime Error
Garbage Value
0
Compile time Error
7 questions
Quiz on Java Operators
Quiz
•
University
10 questions
Latihan1
Quiz
•
University
10 questions
DEBUG THE CODE
Quiz
•
University
10 questions
Wipro-inheritance
Quiz
•
University
10 questions
String_bca
Quiz
•
University
10 questions
На сколько ты знаешь C#
Quiz
•
University
10 questions
Java Control Flow statements
Quiz
•
University
9 questions
Passaggio parametri
Quiz
•
University
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines
Quiz
•
Professional Development
12 questions
Dividing Fractions
Quiz
•
6th Grade