Question 36 / 297:  You have three packages, trunk1,trunk2 and trunk3, What is the expected output of compiling and running file Tester?
Choose 2
package trunk1;

public class Account {

Account() { //line 1

System.out.println("Account");

}

}

package trunk2;

import trunk1.Account;

public class CurrentAccount extends Account{

public CurrentAccount() { // line 2

System.out.println("CurrentAccount");

}

}

package trunk3;

import trunk1.Account;

import trunk2.CurrentAccount; // line 3

public class Tester {

public static void main(String[] args) {

Account c = new Account(); // line 4

CurrentAccount ca = new CurrentAccount();

}

}

<< First < Previous Next > Last >>
Explanation:

Tester (line 4) cant't instantiate an instance of Account because the constructor is invisible (package visible, no modifier). For the same reason a compilation error occurs when CurrentAccount tries to call implicitly super() of class Account at line 2

Exam Home Page
Ask
Brooke Delaney
Start Exam
Edgar Delgado
Start Test
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>