

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
20 questions
Lv 16 Booklet 1 Part 2
Presentation
•
3rd Grade
20 questions
S Blend
Presentation
•
1st Grade
23 questions
Electricity and Magnetism
Presentation
•
3rd Grade
24 questions
asas sains komputer
Presentation
•
1st Grade
24 questions
2nd Grade, 3rd Quarter Review
Presentation
•
2nd Grade
18 questions
Review- Customary Measurement
Presentation
•
3rd Grade
17 questions
Y3A Term 1 STEM Review
Presentation
•
3rd Grade
16 questions
cuestionario
Presentation
•
3rd Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade