Java Classes & Objects

Quiz
•
Computers
•
University
•
Hard
Jeevitha P
Used 256+ times
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
10 questions
Talent Next Java MCQ-1

Quiz
•
University
7 questions
Java Programming Game

Quiz
•
University
10 questions
Temel Java Bilgisi Ölçme Testi

Quiz
•
University
10 questions
FGCT4023 Topic 5 - Colour & Text

Quiz
•
University
10 questions
java quiz on Encapsulation and Abstraction

Quiz
•
University
10 questions
Control Statements in JAVA

Quiz
•
University
10 questions
C Programming Quiz-5

Quiz
•
University
8 questions
Condition Statements -1

Quiz
•
University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University