Clarifications

Dear Ms. Geetha,

I have populated the Array for the Channel 5 class and it is correct, but I am not sure as to how to make it print. I tried doing System.out.println(watcherReports); at the end of the constructor, and I tried System.out.println(watcherReports[k].getHighTemp + hotLocation); at the end of the if loop for the main method. I also tried adding public static void main at the end, it did not work

Can you please tell me how to make it print? Thank you Sitara

Sitara, Long is one of the primitive data type. However long is not part of the AP subset. Yes you can do the program without long...

> Ms. Geetha 17/1/2012 9:13 am
 * **int**: The int data type is a 32-bit signed two's complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use, but if you need a wider range of values, use long instead.
 * **long**: It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). Use this data type when you need a range of values wider than those provided by int
 * I hope it helps...

Dear Ms. Geetha

I was doing the long division lab and found somewhere in the book that there is a primitive type called Long which you can use when you want to find answers more than int or double, apparently when I tried this in my program it worked.

My question is, is there a way to do the program without long, and what does it actually do?

Sitara

Encapsulation - Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction. Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding. Encapsulation can be described as a protective barrier that prevents the code and data being randomly accessed by other code defined outside the class. Access to the data and code is tightly controlled by an interface. The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code.

Dear Ms. Geetha,

Here are the doubts that I have

I would like to confirm the exact definition of polymorphism, I believe it involves the use of a common method in a parent and child class that could change in purpose from class to class, is this correct?


 * Kind of yes... when you have a sub class overriding the method which is defined by the super class**
 * Bank Account b1=new SavingsAccount**
 * withdraw method has been overridden in Savings Account**
 * when you run it with b1.withdraw only the withdraw method of the savings account will be implemented even though the type is of super class Bank Account**
 * This mechanism of choosing the object's overridden method is called Polymorphism**

Could you please post the code for linear and binary search? I know how binary search works (the computer picks a middle ground, and uses a for each loop to search for the term asked for by the user relative to the middle, and picks a new middle each time the term is not found) but I would like to confirm if this is correct in the book both in page 319

Could you also explain selection sort? It is this concept that I am very unsure about 6 5 2 4 1 10 7 0 1 2 3 4 5 6 First 0 place..... the program will go look for the index with minimum value..... index = 4 So 0 and 4 will exchange place now the order will be 1 5 2 4 6 10 7 Next index 1...... look for the next minimum index and the number index = 2 So index 1 and 2 will exchange position... so on ..until the whole list is sorted...

Thank you very much, Sitara