Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Read the following topic, then explain briefly what did you understand from it?

ID: 3723647 • Letter: R

Question

Read the following topic, then explain briefly what did you understand from it?

Constructor:

Example:

public class BankAccount {

private double balance;

public BankAccount()

{ balance = 0; }

public BankAccount(double initialBalance)

{

balance = initialBalance;

System.out.print("Balance is: ");

System.out.println(balance + 10);

}

}

1- Is public BankAccount() considered as a constructor? Why?

Answer:

Yes, It has the name of the class.

2- What is the output of:

public static void main(String[] args){

new BankAccount(10.5);

}

Answer:

Balance is: 20.5

Explanation / Answer

It can be inferred from the above topic that-

Like in the given example,