About Question enthuware.ocpjp.i.v11.2.3083 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
dimitrilc
Posts: 34
Joined: Sat Jun 06, 2020 4:51 pm
Contact:

About Question enthuware.ocpjp.i.v11.2.3083 :

Post by dimitrilc »

So, in conclusion, is it because
1. the class Logger already imported java.util.ArrayList that
2. calling ArrayList methods on a Logger instance does not need TestClass to import java.util.ArrayList?
3. Unless TestClass creates a new instance of ArrayList?, such as

Code: Select all

ArrayList al = new ArrayList();

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.i.v11.2.3083 :

Post by admin »

>>2. calling ArrayList methods on a Logger instance does not need TestClass to import java.util.ArrayList?
You can't call ArrayList methods on a Logger instance! Logger is not an ArrayList. If you mean, calling methods of Logger instance that return ArrayList, does not require ArrayList to be imported.

Bottom line is, if you use the word ArrayList in a class, then that class needs to import ArrayList (or the package java.util) for the compiler to understand what you mean by it.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests