Question
can someone help explain this for me?
In the class we discussed the class Account, suppose we have a constructor accepting one number as the parameter to indicate
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Account[] acc1 = new Account[30]; //The computer creates an array of object named as acc1

Account acc2 = new Account(30);     //The computer will create an object named as acc2

Difference between the two statements are as follows:

1st statement: It executes it the following manner->

acc1[0] = new Account();   acc1[1] = new Account();.................................................acc1[29] = new Account();

It creates an array of object of length size = 30 (0 to 29)

2nd statement: It executes it the following manner->

Account constructor is used to give acc2 an initial balance of 30.

Add a comment
Know the answer?
Add Answer to:
can someone help explain this for me? In the class we discussed the class Account, suppose...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PROGRAMMING 1. The LinkList class that we discussed in class is implemented using pointer t constructed...

    PROGRAMMING 1. The LinkList class that we discussed in class is implemented using pointer t constructed with a list of nodes, and the first node pointer points to the front I a) (10 pts) Complete the following class declaration which is similar to Linklist class ecter class (Write only the prototypes and the private data field; definitions will follow the class declaration) template stypenane T> olass Linkedveoter t private olass Node publie T info Node "next typedet Node *nodePtr publie...

  • I hope someone can explain this exercise to me. Thanks +++++++++++++ Programming Exercise Try to think...

    I hope someone can explain this exercise to me. Thanks +++++++++++++ Programming Exercise Try to think about how to implement KWArrayList class. Please implement the following constructor and methods: public KWArrayList() public boolean add(E anEntry) public E get(int index) { public E set(int index, E newValue) public E remove(int index) private void reallocate() public int size() public int indexOf(Object item)       Study the code for ArrayList implementation (enclosed in the folder) and work on the following exercise Provide a constructor...

  • Can someone help me with the main class of my code. Here is the assignment notes....

    Can someone help me with the main class of my code. Here is the assignment notes. Implement project assignment �1� at the end of chapter 18 on page 545 in the textbook. Use the definition shown below for the "jumpSearch" method of the SkipSearch class. Notice that the method is delcared static. Therefore, you do not need to create a new instance of the object before the method is called. Simply use "SkipSearch.jumpSearch(...)" with the appropriate 4 parameter values. When...

  • can someone help with this? need to use c++. The aim of this homework assignment is...

    can someone help with this? need to use c++. The aim of this homework assignment is to practice writing classes. This homework assignment will help build towards project I, which will be to write a program implementing Management of Rosters System. For this assignment, write a class called Student. This class should contain information of a single student. This information includes: last name, first name, standing, credits gpa, date of birth, matriculation date. For now you can store date of...

  • Can anyone help me with this java program? We are still very early with lessons so...

    Can anyone help me with this java program? We are still very early with lessons so no advanced code please. And if you comment throughout the code that would be incredibly helpful. Thank you Create 2 Java files for this assignment: Die.java and TestDie.java Part 1 - The Die Class             The program Design a Die class that contains the following attributes: sides: represents how many sides a dice has. A dice usually has 6 sides but sometimes could have...

  • Can someone help me with this question? I missed part of the class and need a...

    Can someone help me with this question? I missed part of the class and need a better understanding. Thank you! The time required for Speedy Lube complete an oil change service on an automobile approximately follows a normal distribution, with a mean of 17 minutes and a standard deviation of 2.5 minutes. a) Speedy Lube guarantees customers that the service will take no longer than 20 minutes. If it does take longer, the customer will receive the service half-price. What...

  • Complete the CashRegister class by implementing the methods and adding the correct attributes (characteristics) as discussed...

    Complete the CashRegister class by implementing the methods and adding the correct attributes (characteristics) as discussed in class. Once complete, test the class using the CashRegisterTester class. Make sure you have 3 total items in the cash register. I have two classes, the first is CashRegisterTester below: public class CashRegisterTester { public static void main(String[] args) { //Initialize all variables //Construct a CashRegister object CashRegister register1 = new CashRegister(); //Invole a non-static method of the object //since it is non-static,...

  • Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default...

    Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default values for balance #and annual interest rate are 100 and e, respectively). #INITIALIZER METHOD HEADER GOES HERE #MISSING CODE def getId(self): return self._id def getBalance(self): #MISSING CODE def getAnnualInterestRate(self): return self.___annualInterestRate def setBalance(self, balance): self. balance - balance def setAnnualInterestRate(self,rate): #MISSING CODE def getMonthlyInterestRate(self): return self. annualInterestRate/12 def getMonthlyInterest (self): #MISSING CODE def withdraw(self, amount): #MISSING CODE det getAnnualInterestRate(self): return self. annualInterestRate def setBalance(self,...

  • Can someone help me solving this? B6. A study is conducted in a class of 360 students investigating the problem of screen cracking in mobile phones. We assume that a) the number of screen cracking eve...

    Can someone help me solving this? B6. A study is conducted in a class of 360 students investigating the problem of screen cracking in mobile phones. We assume that a) the number of screen cracking events follows a Poisson distributiorn and that b) the expected rate of screen cracking is 1 in 3 per phone per year. i) Write down the formula for the probability mass function of a Poisson random variable withh 3 marks parameter X, stating also the...

  • 4. Consider the consumption-leisure choice model we discussed in class. Suppose individual utility is represented by...

    4. Consider the consumption-leisure choice model we discussed in class. Suppose individual utility is represented by the function U(c, L) = min {c, 10L}, where c is consumption and L is leisure. Individuals have a total h = 16 hours that could be divided into work and leisure. Market wage rate is w = 10. (a) Sketch the individual’s indifference curve. (b) Find the optimal consumption and leisure choice. (c) Now suppose wage increases to w = 12. Find the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT