logo

Crowdly

Browser

Add to Chrome

Assume that you want to test the class ArrayList of java.util with the following...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Assume that you want to test the class ArrayList of java.util with the following JUnit test class:

class TestArrayList {

    ArrayList<Integer> al;

    @BeforeEach

    void setUp() throws Exception {   

        al = new ArrayList<>();

        al.add(10); al.add(20); al.add(30);

    }

    @AfterEach

    void tearDown() throws Exception {

    }

    @Test

    void test1() {

        al.add(1);

        assertEquals(1,al.get(0));

    }

    

    @Test

    void test2() {

         al.add(1);

        assertFalse(al.contains(1));

    }

    

    @Test

    void test3() {

        assertTrue(al.contains(20));

    }

    

    @Test

    void test4() {

        al.clear();

        assertEquals(10,al.get(0));

    }

}

Which of the test cases result in a success?

a) test1()

b) test2()

c) test3()

d) test4()

0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.jku.at?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome