

Java Programming
Presentation
•
Computers
•
2nd Grade
•
Practice Problem
•
Hard
Dr. K
Used 1K+ times
FREE Resource
1 Slide • 22 Questions
1
Java Programming

2
Multiple Choice
What is the range of short data type in Java?
-128 to 127
-32768 to 32767
-2147483648 to 2147483647
None of the mentioned
3
Multiple Choice
Modulus operator, %, can be applied to which of these?
Integers
Floating – point numbers
Both Integers and floating – point numbers
None of the mentioned
4
Multiple Choice
class evaluate {
public static void main(String args[]) {
int a[] = {1,2,3,4,5}; int d[] = a; int sum = 0;
for (int j = 0; j < 3; ++j)
sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]);
System.out.println(sum); } }
38
39
41
40
5
Multiple Choice
Which of these can be returned by the operator &?
Integer
Boolean
Character
Integer or Boolean
6
Multiple Choice
class dynamic_initialization {
public static void main(String args[]) {
double a, b; a = 3.0; b = 4.0;
double c = Math.sqrt(a * a + b * b);
System.out.println(c); } }
5.0
25.0
7.0
Compilation Error
7
Multiple Choice
When Overloading does not occur?
More than one method with same name but different method signature and different number or type of parameters
More than one method with same name, same signature but different number of signature
More than one method with same name, same signature, same number of parameters but different type
More than one method with same name, same number of parameters and type but different signature
8
Multiple Choice
Which of these statements are incorrect?
Assignment operators are more efficiently implemented by Java run-time system than their equivalent long forms
Assignment operators run faster than their equivalent long forms
Assignment operators can be used only with numeric and character data type
None of the mentioned
9
Multiple Choice
class increment {
public static void main(String args[]) {
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
int var4 = var3 / 4;
System.out.print(var2 + " " + var4); } }
1 1
0 1.5
1.5 1
1 1.5
10
Multiple Choice
class increment {
public static void main(String args[]) {
int g = 3;
System.out.print(++g * 8); } }
24
32
25
34
11
Multiple Choice
class Output {
public static void main(String args[]) {
int a = 1; int b = 2; int c; int d;
c = ++b;
d = a++;
c++;
b++;
++a;
System.out.println(a + " " + b + " " + c); } }
4 4 3
3 3 4
3 4 4
4 3 3
12
Multiple Choice
class bitwise_operator {
public static void main(String args[]) {
int var1 = 42;
int var2 = ~var1;
System.out.print(var1 + " " + var2); } }
42 42
42 -43
43 42
43 -42
13
Multiple Choice
class bitwise_operator {
public static void main(String args[]) {
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d); } }
7 2
7 5
5 7
7 7
14
Multiple Choice
class leftshift_operator {
public static void main(String args[]) {
byte x = 64; int i; byte y;
i = x << 2;
y = (byte) (x << 2)
System.out.print(i + " " + y); } }
0 256
256 0
0 64
256 1
15
Multiple Choice
class rightshift_operator {
public static void main(String args[]) {
int x; x = 10;
x = x >> 1;
System.out.println(x); } }
2
7
5
10
16
Multiple Choice
Which of these keywords can be used to prevent Method overriding?
static
constant
protected
final
17
Multiple Choice
At line number 2 in the following code, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected”
public interface Status {
/* insert qualifier here */ int MY_VALUE = 10;
}
final, native, private
final, static, protected
final, private, abstract
final, static, public
18
Multiple Choice
What will be the output of the following Java program?
class Alligator {
public static void main(String[] args) {
int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
int [][]y = x;
System.out.println(y[2][1]); } }
2
3
7
Compilation Error
19
Multiple Choice
What will be the output of the following Java program?
class Abc {
public static void main(String[]args) {
String[] elements = { "for", "tea", "too" };
String first = (elements.length > 0) ? elements[0]: null; } }
Compilation error
An exception is thrown at run time
The variable first is set to null
The variable first is set to elements[0]
20
Multiple Choice
What will be the output of the following Java program?
class selection_statements {
public static void main(String args[]) {
int var1 = 5; int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2); } }
1
3
2
5
21
Multiple Choice
What will be the output of the following Java program?
class Output {
public static void main(String args[]) {
final int a=10,b=20;
while(a<b)
{
System.out.println("Hello"); }
System.out.println("World"); } }
Hello
run time error
Hello world
compile time error
22
Multiple Choice
What will be the output of the following Java program?
class Alligator {
public static void main(String[] args) {
int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
int [][]y = x;
System.out.println(y[2][1]); } }
2
3
7
Compilation Error
23
Multiple Choice
class increment {
public static void main(String args[]) {
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
int var4 = var3 / 4;
System.out.print(var2 + " " + var4); } }
1 1
0 1.5
1.5 1
1 1.5
Java Programming

Show answer
Auto Play
Slide 1 / 23
SLIDE
Similar Resources on Wayground
17 questions
Python
Lesson
•
1st Grade
14 questions
Temas Bimestre II
Lesson
•
1st - 3rd Grade
16 questions
Mr. Stein spelling lesson #12
Lesson
•
2nd - 3rd Grade
20 questions
Tipos Primitivos
Lesson
•
3rd Grade
20 questions
Python основы
Lesson
•
KG
15 questions
Forces 12/1/23
Lesson
•
1st Grade
23 questions
3rd P1Q2 In-Class Review
Lesson
•
2nd Grade
18 questions
Python 8 класс итог
Lesson
•
1st Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
14 questions
Boundaries & Healthy Relationships
Lesson
•
6th - 8th Grade
13 questions
SMS Cafeteria Expectations Quiz
Quiz
•
6th - 8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
SMS Restroom Expectations Quiz
Quiz
•
6th - 8th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
10 questions
Pi Day Trivia!
Quiz
•
6th - 9th Grade
Discover more resources for Computers
10 questions
Map Skills Quiz
Quiz
•
2nd Grade
10 questions
Wayground Quiz Review for G2 Benchmark 3
Quiz
•
2nd Grade
17 questions
2nd Grade Graphs (Bar & Picture)
Quiz
•
2nd Grade
15 questions
Telling Time
Quiz
•
2nd Grade
10 questions
Telling Time to the Nearest 5 Minutes
Quiz
•
2nd Grade
30 questions
Multiplication Facts 1-12
Quiz
•
2nd - 5th Grade
14 questions
Main Idea
Quiz
•
2nd - 3rd Grade
10 questions
3 Digit Addition and Subtraction with Regrouping
Quiz
•
2nd - 4th Grade