
java 3
Quiz
•
Arts
•
1st Grade
•
Hard
Nagendrapatel Puppala
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following java program?
public class Outer
{
public static int temp1 = 1;
private static int temp2 = 2;
public int temp3 = 3;
private int temp4 = 4;
public static class Inner
{
private static int temp5 = 5;
private static int getSum()
{
return (temp1 + temp2 + temp3 + temp4 + temp5);
}
}
public static void main(String[] args)
{
Outer.Inner obj = new Outer.Inner();
System.out.println(obj.getSum());
}
}
15
9
5
compile error
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
// Main.java
public class Main
{
public static void main(String args[])
{
short s = 0;
int x = 07;
int y = 08;
int z = 112345;
s += z;
System.out.println("" + x + y + s);
}
}
find out the error??
Compile Error at line 8
Compile Error at line 6
Compile Error at line 4
Compile Error at line 5
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
// Main.java
public class Main
{
public static void gfg(String s)
{
System.out.println("String");
}
public static void gfg(Object o)
{
System.out.println("Object");
}
public static void gfg(Integer i)
{
System.out.println("Integer");
}
public static void main(String args[])
{
gfg(null);
}
}
find the error???
Compile Error at line 19
Compile Error at line 15
Compile Error at line 12
Compile Error at line 09
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
class ThreadEx extends Thread
{
public void run()
{
System.out.print("Hello...");
}
public static void main(String args[])
{
ThreadEx T1 = new ThreadEx();
T1.start();
T1.stop();
T1.start();
}
}
find the type of error??
compile time
run time
no error
executes
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
public class Test
{
private int data = 5;
public int getData()
{
return this.data;
}
public int getData(int value)
{
return (data+1);
}
public int getData(int... value)
{
return (data+2);
}
public static void main(String[] args)
{
Test temp = new Test();
System.out.println(temp.getData(7, 8, 12));
}
}
find the output of the code???
7
runtime error
compile time error
9
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
interface OuterInterface
{
public void InnerMethod();
public interface InnerInterface
{
public void InnerMethod();
}
}
public class Outer implements OuterInterface.InnerInterface, OuterInterface
{
public void InnerMethod()
{
System.out.println(100);
}
public static void main(String[] args)
{
Outer obj = new Outer();
obj.InnerMethod();
}
}
find the code outcome??
compile time
runtime
100
none
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
public class MyStuff
{
String name;
MyStuff(String n) { name = n; }
public static void main(String[] args)
{
MyStuff m1 = new MyStuff("guitar");
MyStuff m2 = new MyStuff("tv");
System.out.println(m2.equals(m1));
}
@Override
public boolean equals(Object obj)
{
MyStuff m = (MyStuff) obj;
if (m.name != null) { return true; }
return false;
}
}
find the outcome of the code??
The output is true and MyStuff fulfills the Object.equals() contract.
The output is false and MyStuff fulfills the Object.equals() contract.
The output is true and MyStuff does NOT fulfill the Object.equals() contract
The output is false and MyStuff does NOT fulfill the Object.equals()
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
15 questions
Choose the correct "Instrument Family"
Quiz
•
1st - 4th Grade
20 questions
Impresionismo Musical
Quiz
•
KG - Professional Dev...
15 questions
doors quiz 15 questions
Quiz
•
1st - 5th Grade
20 questions
Resource Economics
Quiz
•
1st Grade - University
20 questions
unit 3
Quiz
•
1st Grade - University
20 questions
Monetary Economics March 2024
Quiz
•
1st Grade
19 questions
LL Music - Q1 Test
Quiz
•
1st - 5th Grade
15 questions
Music
Quiz
•
1st Grade
Popular Resources on Wayground
10 questions
Honoring the Significance of Veterans Day
Interactive video
•
6th - 10th Grade
10 questions
Exploring Veterans Day: Facts and Celebrations for Kids
Interactive video
•
6th - 10th Grade
19 questions
Veterans Day
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
Circuits, Light Energy, and Forces
Quiz
•
5th Grade
6 questions
FOREST Self-Discipline
Lesson
•
1st - 5th Grade
7 questions
Veteran's Day
Interactive video
•
3rd Grade
20 questions
Weekly Prefix check #2
Quiz
•
4th - 7th Grade
Discover more resources for Arts
6 questions
FOREST Self-Discipline
Lesson
•
1st - 5th Grade
13 questions
Veterans' Day
Quiz
•
1st - 3rd Grade
15 questions
Natural Resources
Quiz
•
KG - 2nd Grade
20 questions
Place Value
Quiz
•
KG - 3rd Grade
16 questions
natural resources
Quiz
•
1st Grade
20 questions
Identify Coins and Coin Value
Quiz
•
1st Grade
24 questions
Addition
Quiz
•
1st Grade
7 questions
Water Conservation
Quiz
•
1st Grade
