Search Header Logo

Java I/O streams, Files and collection frameworks

Authored by Benila S

Computers

University

Java I/O streams, Files and collection frameworks
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

22 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following declarations don't compile?

A)List<?> l1 = new ArrayList<>();

B)List<String> l2 = new ArrayList();

C) List<? super Object> l3 = new ArrayList<String>();

D) List<? extends Object> l4 = new ArrayList<String>();

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Question {

public static void main(String[] args) {

Question q = new Question();

List<Integer> l = new ArrayList<>();

l.add(20); l.add(30); q.m1(l); }

private void m1(List<?> l) { m2(l); // 1 }

private <T> void m2(List<T> l)

{ l.set(1, l.get(0)); // 2

System.out.println(l);

}

}

A) [20, 20]

B) Compilation fails on the line marked as // 1

C) Compilation fails on the line marked as // 2

D) An exception occurs at runtime

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Question <T extends Number> {

T t;

public static void main(String[] args) {

Question q = new Question<Integer>(); // 1

q.t = new Float(1); // 2

System.out.println(q.t);

}

}

A. 1.0

B. Compilation fails on the line marked as // 1

C. Compilation fails on the line marked as // 2

D. An exception occurs at runtime

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import java.util.*;

class UtilitiesTest {

public static void main(String[] args) {

List < int > intList = new ArrayList < > ();

intList.add(10);

intList.add(20);

System.out.println("The list is: " + intList);

A) It prints the following: The list is: [10, 20] 

B) It prints the following: The list is: [20, 10] 

C. It results in a compiler error 

D. It results in a runtime exception

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which interface represents a resizable array of objects in Java Collections?

a) Set

b) List

c) Map

d) Queue

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these is not a method defined in the Map interface?

a) put()

b) get()

c) remove()

d) add()

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these interfaces is not part of the Java Collections Framework?

d) Sortable

a) List

b) SortedMap

c) SortedSet

d) Sortable

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?