Java Instance

Quiz
•
Computers
•
University
•
Hard
Thomas Martinez
FREE Resource
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Predict the output of following Java program?
class Test {
int i;
}
class Main {
public static void main(String args[]) {
Test t;
System.out.println(t.i);
}
0
garbage value
Compiler Error
Run Time Error
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Predict the output of following Java program
class Test
{ int i;
}
class Main
{ public static void main(String args[])
{ Test t = new Test();
System.out.println(t.i);
} }
Garbage Value
0
Compiler Error
Runtime error
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
class demo
{
int a, b;
demo()
{
a = 10;
b = 20;
}
public void print()
{
System.out.println ("a = " + a + " b = " + b );
}
}
class Test
{
public static void main(String[] args)
{
demo obj1 = new demo();
obj1.a += 1;
obj1.b += 1;
System.out.println ("values of obj1 : ");
obj1.print();
}
}
Compile error
values of obj1:
a = 11 b = 21
values of obj1:
a = 10 b = 20
Runtime Error
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following program?
public class Rose {
public Rose(String name) {
System.out.println("Passed Name is :" + name);
}
public static void main(String[] args) {
Rose myRose = new Rose("red");
myRose = new Rose("white");
}
}
Passed Name is :red
Passed Name is :white
Passed Name is :red
Passed Name is :white
Compilation Error or Runtime Error
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given that Student is a class, how many reference variables and objects are created by the following
Student studentName, studentId; studentName = new Student(); Student stud_class = new Student();
Three reference variables and two objects are created.
Two reference variables and two objects are created.
One reference variable and two objects are created
Three reference variables and three objects are created.
Similar Resources on Wayground
6 questions
Java Method Overloading

Quiz
•
University
10 questions
Core Java Quiz

Quiz
•
University
6 questions
Java array

Quiz
•
11th Grade - University
10 questions
String_bca

Quiz
•
University
5 questions
Java Classes & Objects

Quiz
•
University
10 questions
Third Year Placement Training Revision Test

Quiz
•
University
10 questions
Latihan1

Quiz
•
University
10 questions
DEBUG THE CODE

Quiz
•
University
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

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

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade