Search Header Logo

Collection2

Authored by khushbu mehta

Philosophy

1st Grade

Used 3+ times

Collection2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

Which of the following are true about the following code? (Choose all that apply)

public class Create {

Create() { System.out.print("1 "); }

Create(int num) {

System.out.print("2 "); }

Create(Integer num) {

System.out.print("3 "); }

Create(Object num) {

System.out.print("4 "); }

Create(int... nums) { System.out.print("5 "); }

public static void main(String[] args) {

new Create(100);

new Create(1000L); } }

2 4

3 4

2 5

compile error

2.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

Which of the following lambda expressions can fill in the blank?

List list = new ArrayList<>();

list.removeIf(___________________);

s -> s.isEmpty()

s -> {s.isEmpty()}

s -> {s.isEmpty();}

s -> {return s.isEmpty();}

3.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What is the result of the following statements?

3: ArrayList<Integer> values = new ArrayList<>();

4: values.add(4);

5: values.add(5);

6: values.set(1, 6);

7: values.remove(0);

8: for (Integer v : values)

System.out.print(v);

5

6

4

compile error

4.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What will be the output?

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

ages.add(Integer.parseInt("5"));

ages.add(Integer.valueOf("6"));

ages.add(7);

ages.add(null);

for (int age : ages) System.out.print(age);

5 6 7

Compilation error

Runtime exception

5.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

List<String> one = new ArrayList<String>();

one.add("abc");

List<String> two = new ArrayList<>();

two.add("abc");

if (one == two)

System.out.println("A");

else if (one.equals(two))

System.out.println("B");

else

System.out.println("C");

A

B

C

Run time exception

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?