PRG/420 Version 10 All Weeks DQ’s ( ORIGINAL )
- Java™ is a portable language, and being an object-oriented programming language, it also encourages component reusability. How does Java™ achieve these two important features? How are these features desirable in modern software engineering?
- You are a bank manager and you are helping a new bank teller understand the kind of accounts the bank offers. If a customer comes in asking to open a new savings account, the teller needs to ask what kind of account—passbook savings or certificate of deposit—the customer would like to open. Remind the customer that all accounts with our bank are insured by the FDIC. You should explain that all accounts earn some interest; a savings account’s interest is compounded monthly. You should assign a unique account number after accepting the customer’s initial deposit. If the customer chooses to receive statements electronically, the system will send an e-mail with a monthly statement; if the customer chooses not to, then a paper statement will be sent by mail quarterly.
If savings account is a class, give an example of each of the following as it relates to that savings account. Explain your reasoning behind your example.
- Instance (object)
- What are the three types of errors that you can encounter in a Java™ program? Describe them, and explain how you would minimize the errors. What are some examples of errors that you have seen before?
- A class is a blueprint for an object. A class may have a default constructor, a constructor with arguments, accessor methods, mutator methods, public fields, and private fields. Choose a category (such as animal, vehicle, and so on) and describe how you would design a class for it.
Select and complete one of the following activities:
Convert the following program from forloop to whileloop.
public static void main (String  args)
int sum = 0;
for (int i = 1; i <= 1000; i++)
sum = sum + i;
Compare the efficiency between a forloop and a whileloopin the same program. Your program should be able to tell if a forloop is faster than a while-loop at the end of the program. Include the result of your run with the information on which one isfaster.
- There are 3 kinds of loops—for loop, while loop, and do while loop. Under which circumstances would each kind of loop be more appropriate? Explain your answers using specific examples.
- What is the difference between arrays and ArrayList? What are the advantages and disadvantages of an ArrayList, and when should you use an ArrayList over a simple array?
- What is the difference between string and StringBuilder? What are the advantages and disadvantages of a StringBuilder, and when should you use a StringBuilder over a simple String?
- In your opinion, what are the three biggest challenges in planning and designing a solution for a programming problem? What can you do to overcome these challenges? How would you apply these techniques to the programs in this class?
- Using an example from your work or daily life, describe an “is-a” relationship. Why is an “is-a” relationship important when designing an inheritance between classes?