Search Header Logo

JAVA

Authored by kalyani boyina

Architecture

4th Grade

Used 2+ times

JAVA
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

38 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java code?

  1. class increment {

  2. public static void main(String args[])

  3. {

  4. int g = 3;

  5. System.out.print(++g * 8);

  6. }

  7. }

A) 32

B) 33

C) 24

D) 25

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java program?

  1. class output {

  2. public static void main(String args[]){

  3. double a, b,c;

  4. a = 3.0/0;

  5. b = 0/4.0;

  6. c=0/0.0; 

  7. System.out.println(a);

  8. System.out.println(b);

  9. System.out.println(c);

  10. }

  11. }

Infinity
NaN
Infinity 0.0 NaN
0.0

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java program?

  1. class variable_scope

  2. {

  3. public static void main(String args[])

  4. {

  5. int x;

  6. x = 5;

  7. {

  8. int y = 6;

  9. System.out.print(x + " " + y);

  10. }

  11. System.out.println(x + " " + y);

  12. }

  13. }



a) Compilation error

b) Runtime error

c) 5 6 5 6

d) 5 6 5

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java program?

  1. class leftshift_operator

  2. {

  3. public static void main(String args[])

  4. {

  5. byte x = 64;

  6. int i;

  7. byte y;

  8. i = x << 2;

  9. y = (byte) (x << 2);

  10. System.out.print(i + " " + y);

  11. }

  12. }

256 0
256 64
64 0
128 0

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java code?

  1. class box

  2. {

  3. int width;

  4. int height;

  5. int length;

  6. }

  7. class main

  8. {

  9. public static void main(String args[])

  10. {

  11. box obj = new box();

  12. obj.width = 10;

  13. obj.height = 2;

  14. obj.length = 10;

  15. int y = obj.width * obj.height * obj.length;

  16. System.out.print(y);

  17. }

  18. }


100

400

200

12

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is Truncation in Java?

Floating point value is assigned to floating type

Floating point value assigned to integer type.

Integer point value assigned to integer type

Integer point value assigned to floating type

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java program?

  1. class Output

  2. {

  3. public static void main(String args[])

  4. {

  5. int arr[] = {1, 2, 3, 4, 5};

  6. for ( int i = 0; i < arr.length - 2; ++i)

  7. System.out.print(arr[i] + " ");

  8. }

  9. }

1 2 3 4
2 3 4 5
0 1 2
1 2 3

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?