Knowee
Questions
Features
Study Tools

Drag and drop the apt option in the space provided to get the output as “Account Number : 1001, Holder : Chandru, Balance : 50000”.Code :public class Account {       private int accountNumber; private String holderName;  private double balance;                    public Account(int accountNumber, String holderName, double balance) {              this.accountNumber = accountNumber;              this.holderName = holderName;  this.balance = balance;       }        //Override toString method        blank    blank    blank {                 blank   "Account Number : "+accountNumber+", Holder : "+holderName                                                         +", Balance : "+balance;       }}public class Main  {       public static void main(String args[]) {              Account accObj1=new Account(1001,"Chandru",50000);              blank ( blank );                    }}   System.out.println public toString( ) return String accObj1

Question

Drag and drop the apt option in the space provided to get the output as “Account Number : 1001, Holder : Chandru, Balance : 50000”.Code :public class Account {       private int accountNumber; private String holderName;  private double balance;                    public Account(int accountNumber, String holderName, double balance) {              this.accountNumber = accountNumber;              this.holderName = holderName;  this.balance = balance;       }        //Override toString method        blank    blank    blank {                 blank   "Account Number : "+accountNumber+", Holder : "+holderName                                                         +", Balance : "+balance;       }}public class Main  {       public static void main(String args[]) {              Account accObj1=new Account(1001,"Chandru",50000);              blank ( blank );                    }}   System.out.println public toString( ) return String accObj1

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct code would be:

public class Account {
    private int accountNumber;
    private String holderName;
    private double balance;

    public Account(int accountNumber, String holderName, double balance) {
        this.accountNumber = accountNumber;
        this.holderName = holderName;
        this.balance = balance;
    }

    //Override toString method
    public String toString() {
        return "Account Number : "+accountNumber+", Holder : "+holderName+", Balance : "+balance;
    }
}

public class Main {
    public static void main(String args[]) {
        Account accObj1=new Account(1001,"Chandru",50000);
        System.out.println(accObj1);
    }
}

So, the correct options to fill in the blanks are:

  1. public
  2. String
  3. toString()
  4. return
  5. System.out.println
  6. accObj1

This problem has been solved

Similar Questions

public class Account{       private int accountNumber;       private String holderName;       private double balance;                    public Account(int accountNumber, String holderName, double balance) {              this.accountNumber = accountNumber;              this.holderName = holderName;              this.balance = balance;       } } public class Main{       public static void main(String args[]) {              Account accObj1=new Account(1001,"Chandru",50000);                           System.out.println(accObj1);                    }}If the above code should give the output as “Account Number : 1001, Holder : Chandru, Balance : 50000”, which method should be overridden and that method should be written in which class.Select one:a.Override toString() method in Account classb.Override tostring() method in Account classc.Override tostring() method in Main classd.Override toString() method in Main class

Declare a method public double calculateInterest() in the class Account. Just declare this method without providing any definition/implementation.Make necessary changes to the class declaration. public class Account{       private int accountNumber;       private String holderName;       private double balance;                 // Declare the method calculateInterest              }

// BankAccount.java// Parent class BankAccountpublic class BankAccount { private String accountNumber; private double balance; public BankAccount(String accountNumber, double balance) { this.accountNumber = accountNumber; this.balance = balance; } public void deposit(double amount) { balance += amount; } public void withdraw(double amount) { if (balance >= amount) { balance -= amount; } else { System.out.println("Insufficient balance"); } } public double getBalance() { return balance; }}Copy// SavingsAccount.java// Child class SavingsAccountpublic class SavingsAccount extends BankAccount { public SavingsAccount(String accountNumber, double balance) { super(accountNumber, balance); } @Override public void withdraw(double amount) { if (getBalance() - amount < 100) { System.out.println("Minimum balance of $100 required!"); } else { super.withdraw(amount); } }}Copy // Main.java// Main classpublic class Main { public static void main(String[] args) { System.out.println("Create a Bank Account object (A/c No. BA1234) with initial balance of $500:"); //Create a BankAccount object (A/c No. "BA1234") with initial balance of $500 BankAccount BA1234 = new BankAccount("BA1234", 500); // Deposit $1000 into account BA1234 System.out.println("Deposit $1000 into account BA1234:"); BA1234.deposit(1000); System.out.println("New balance after depositing $1000: $" + BA1234.getBalance()); // Withdraw $600 from account BA1234 System.out.println("Withdraw $600 from account BA1234:"); BA1234.withdraw(600); System.out.println("New balance after withdrawing $600: $" + BA1234.getBalance()); // Create a SavingsAccount object (A/c No. "SA1234") with initial balance of $450 System.out.println("\nCreate a SavingsAccount object (A/c No. SA1234) with initial balance of $450:"); SavingsAccount SA1234 = new SavingsAccount("SA1234",450); // Withdraw $300 from SA1234 SA1234.withdraw(300); System.out.println("Balance after trying to withdraw $300: $" + SA1234.getBalance()); // Create a SavingsAccount object (A/c No. "SA1000") with initial balance of $300 System.out.println("\nCreate a SavingsAccount object (A/c No. SA1000) with initial balance of $300:"); SavingsAccount SA1000 = new SavingsAccount("SA1000",300); // Withdraw $250 from SA1000 (balance falls below $100) System.out.println("Try to withdraw $250 from SA1000!"); SA1000.withdraw(250); System.out.println("Balance after trying to withdraw $250: $" + SA1000.getBalance()); }}

Fill with the apt data type for the variable result.public class Main{    public static void main(String args[])    {                int  number1=10;                double number2 = 54.5;                Answer  result = number1 + number2;    }}

Write a java program to create a bank account with Name of the account holder, type of account(savings or  current), Account number and Balance amount in the account. Also, create 5 customers for the class Bank_account using array of objects. Access the customers to perform credit, debit and display of balance.Input 1:Enter the customers:ReenaSavings1231000RobinCurrent4562000PraveenSavings7893000SherinCurrent2342500DeenaSavings5672000Enter choice:1. Credit2. Debit Output :ReenaSavings1232000

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.