Page 1 of 1

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

Posted: Thu Jul 09, 2020 6:41 pm
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();

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

Posted: Fri Jul 10, 2020 12:59 am
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.