Shared Flashcard Set

Details

Java FAQ
Java FAQ
13
Computer Science
Professional
03/20/2007

Additional Computer Science Flashcards

 


 

Cards

Term
Difference between String, StringBuffer and StringBuilder
Definition
String is immutiable, StringBuffer is mutable but thread safe, StringBuilder is thread unsafe.
Term
As Coding convention class name begins with _ case and variable name with _ case
Definition
CLass Names begin with uppercase eg: class EmployeesOfLehman {
...
}
variable with lowercase eg:
int noOfEmployees
Term
what is difference between final, finally, and finalize
Definition
.final class cannot be extended, final variable cannot be changes, and final method cannot be overridden.

.finally is tha last block in try catch block it is always run regardless.

. finalize is executed when an object garbage collected.
Term
Difference between function overriding vs. function hiding
Definition
Class (static) methods with the same signature in both parent and chlid class result in hiding.
Instance methods results in overriding.
Term
what are some of the methods provided by Object class
Definition
HashCode(), finalize(), toString(), equals
Term
How can u obtain number of active java threads from java
Definition
use activeCount()
Term
Why should wait be always called in while loop
Definition
Always invoke wait inside a loop that tests for the condition being waited for. Don't assume that the interrupt was for the particular condition you were waiting for, or that the condition is still true.
Term
what is transient keyword
Definition
a variable declared transient will not be seralized
Term
what is volatile keyword
Definition
since each thread has it own stack segment local variables are not shared between threads. But if u want to synch the value of a local variable between threads then use volatile. If one thread will update the value all others will get the updated value if the local variable is declared as volatile
Term
In HashMap how would you fine tune, ie reduce collision.
Definition
Fine tuning is done based on load factor. Load factor is defaulted to .75, which means that when hash table is 75% full the increase the size and rehash the table. Also initial capacity could be set so that the first rehashing happens only after a while.
Term
To be able to sort elements in, say, ArrayList the element must implement
Definition
Comparable Interface.
Term
To be able to insert elements into a HashMap the elements must
Definition
implements methods hashCode() and equals()
Term
difference between equals() method and comparable interfafce
Definition
equals() is used with HashCode and compaing object for equality.

Comparable interface is used strictly for sorting purposes.
Supporting users have an ad free experience!