Collections_Generics_ExceptionHandling

Collections_Generics_ExceptionHandling

University

18 Qs

quiz-placeholder

Similar activities

Preparation for the Midterm Assessment - Science Grade IV

Preparation for the Midterm Assessment - Science Grade IV

4th Grade - University

20 Qs

Penilaian Harian Induksi Elektromagnetik

Penilaian Harian Induksi Elektromagnetik

University

15 Qs

Radiation Basic Concepts

Radiation Basic Concepts

University

14 Qs

Mid Test Biokimia

Mid Test Biokimia

University

23 Qs

Machine Learning

Machine Learning

University

20 Qs

CHOPPER 3

CHOPPER 3

University

20 Qs

breast & hirschsprung disease

breast & hirschsprung disease

1st Grade - University

15 Qs

[Q1 BWJ20203] Prokaryotic vs Eukaryotic cell

[Q1 BWJ20203] Prokaryotic vs Eukaryotic cell

University

20 Qs

Collections_Generics_ExceptionHandling

Collections_Generics_ExceptionHandling

Assessment

Quiz

Science

University

Practice Problem

Hard

Created by

pear pear

Used 6+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

18 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Why are ArrayLists better than arrays ?

  • You don't have to decide the size of an ArrayList when you first make it.

  • You can put more items into an ArrayList than into an array.

  • ArrayLists can hold more kinds of objects than arrays.

  • You don't have to decide the type of an ArrayList when you first make it.

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

You get a NullPointerException. What is the most likely cause?

A file that needs to be opened cannot be found.

  • A network connection has been lost in the middle of communications.

  • Your code has used up all available memory.

  • The object you are using has not been instantiated.

3.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

Media Image

What is the output of this code?

[abc, 0, 2, 10]

The code does not compile.

  • [abc, 2, 10, 0]

[0, 10, 2, abc]

4.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Which code snippet is valid ?

  • ArrayList<String> words = new ArrayList<String>(){"Hello", "World"};

  • ArrayList words = Arrays.asList("Hello", "World");

  • ArrayList<String> words = new ArrayList<>(Arrays.asList("Hello", "World"));

  • ArrayList<String> words = {"Hello", "World"};

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Which characteristic does not apply to instances of java.util.HashSet?

  • uses hashcode of objects when inserted

  • contains unordred elements

  • contains unique elements

  • contains sorted elements

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You have an instance of type Map<String, Integer> named instruments containing the following key-value pairs: guitar=1200, cello=3000, and drum=2000. If you add the new key-value pair cello=4500 to the Map using the put method, how many elements do you have in the Map when you call instruments.size()?

2

3

4

  • When calling the put method, Java will throw an exception

7.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

Media Image

What is the result of this code?

  • Hello World

  • It will not compile because the second catch statement is unreachable

Hello World!

It will throw a runtime exception

Create a free account and access millions of resources

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

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?