

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
19 questions
Math Remediation
Presentation
•
3rd - 4th Grade
15 questions
Python- podstawy QUIZ
Presentation
•
1st Grade
19 questions
Traveling and Bouncing Light
Presentation
•
3rd Grade
18 questions
Excel Reading and Comprehension - Pg. 36 - 37
Presentation
•
1st Grade
15 questions
jobs and world
Presentation
•
3rd Grade
12 questions
Reading Skills Review
Presentation
•
1st - 3rd Grade
18 questions
Two-Syllable Words with Blends
Presentation
•
KG - 3rd Grade
12 questions
Data Analysis
Presentation
•
3rd Grade
Popular Resources on Wayground
10 questions
Factors 4th grade
Quiz
•
4th Grade
10 questions
Cinco de Mayo Trivia Questions
Interactive video
•
3rd - 5th Grade
13 questions
Cinco de mayo
Interactive video
•
6th - 8th Grade
20 questions
Math Review
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
Discover more resources for Computers
30 questions
Multiplication Facts 1-12
Quiz
•
2nd - 5th Grade
20 questions
Mixed Multiplication Facts
Quiz
•
2nd - 5th Grade
20 questions
Multiplication Facts
Quiz
•
2nd - 3rd Grade
18 questions
Counting Money
Quiz
•
2nd Grade
12 questions
Telling Time to the Hour and Half Hour
Quiz
•
1st - 3rd Grade
50 questions
Math Review
Quiz
•
2nd Grade
17 questions
2nd Grade Graphs (Bar & Picture)
Quiz
•
2nd Grade
20 questions
Math Review
Quiz
•
2nd Grade