Search Header Logo

Quizz_TG

Authored by Q Mr.

Other

University

Used 6+ times

Quizz_TG
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

40 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • Ungraded

Media Image

What is the output for the below code ?

Compile fail due to error on line no 2
Compile fail due to error on line no 9
Compile fail due to error on line no 8
15

2.

MULTIPLE CHOICE QUESTION

2 mins • Ungraded

Media Image

What is the output for the below code ? public class A { int k; boolean istrue; static int p; public void printValue() { System.out.print(k); System.out.print(istrue); System.out.print(p); } } public class Test { public static void main(String argv[]) { A a = new A(); a.printValue(); } }

0 false 0
0 true 0
0 0 0
Compile error - static variable must be initialized before use.

3.

MULTIPLE CHOICE QUESTION

2 mins • Ungraded

Media Image

What is the output for the below code ? package com; class Animal { public void printName() { System.out.println("Animal"); } } package exam; import com.Animal; public class Cat extends Animal { public void printName() { System.out.println("Cat"); } } package exam; import com.Animal; public class Test { public static void main(String[] args) { Animal a = new Cat(); a.printName(); } }

Animal
Cat
Animal Cat
Compile Error

4.

MULTIPLE CHOICE QUESTION

2 mins • Ungraded

Media Image

What is the output for the below code ? public class A { static { System.out.println("static"); } { System.out.println("block"); } public A() { System.out.println("A"); } public static void main(String[] args){ A a = new A(); } }

A block static
static block A
static A
A

5.

MULTIPLE CHOICE QUESTION

2 mins • Ungraded

Media Image

What is the output for the below code ? 1. public class Test { 2. public static void main(String[] args){ 3. int i = 010; 4. int j = 07; 5. System.out.println(i); 6. System.out.println(j); 7. } 8. }

8 7
10 7
Compilation fails with an error at line 3
Compilation fails with an error at line 5

6.

MULTIPLE CHOICE QUESTION

2 mins • Ungraded

Media Image

What is the output for the below code ? public class Test { public static void main(String[] args) { String value = "abc"; changeValue(value); System.out.println(value); } public static void changeValue(String a) { a = "xyz"; } }

abc
xyz
Compilation fails
Compilation clean but no output

7.

MULTIPLE CHOICE QUESTION

2 mins • Ungraded

Media Image

try{ File f = new File("a.txt"); }catch(Exception e){ }catch(IOException io){ } Is this code create new file name a.txt ?

True
False
Compilation Error
None

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?