Prabhjot Jassal

+ Follow
since Jul 19, 2010
Merit badge: grant badges
Preparing for OCPJP
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Prabhjot Jassal

Is there any particular reason why StringBuffer does not override equals() method?
why did you loose 9%? :-)..Just kidding, well done
12 years ago
assume you are writing a soccer application :-)..and your task is to keep track of all the goals scored so far at an international level...static modifier is probably the best way to keep track of it
i don't think it would compile as you are trying to access, char c which is an instance variable in static method.
Outer class can not be marked static. This will result in compile time error
Hi Jeet

This question is testing your knowledge about method "overriding" rather than any generics.

All interface methods are implicitly "public abstract" and when you implement any interface you basically overriding its methods. One of the "overriding" rule is the new method can not be MORE restrictive than the original method but could be less restrictive.

in your case we changing the access type from public to default and thus making it more restrictive which violates the method overriding rules.

Hope that helps.
Compile time

Basically this question is associated with method is the responsibility of the compiler to decide which method to run and it makes that decision during compile time.
the variable "building" is of static type but the method getHeight() is not. It is important to note that there could exist only one 1 enum in memory eg

Building b1 = Building.LOW_RISE;
Building b2 = Building.LOW_RISE;

boolean areEqual = b1 == b2;

the value of areEqual is "true"

Could someone please clarify this as well...i am not 100% sure on this
Method or variable can not be static unless you explicitly add the "static" keyword in their declaration.

So, enum method can NOT be implicitly be treated as static...but enum COULD contain static methods
Because you have "declared" variable named "acnt" in the main method, so you could only use it only in the main method not anywhere else. It a local variable rather than being an instance variable
Hi's always better to know the latest objectives as they been changing quite frequently in last couple of months

I assume you taking exam in check out this link

Latest Topics Removed

1. Serialization.
2. Thread Interaction (Objective 4.4 no longer there)
3. Drag and drop

Nevertheless, it is always better to know these topics as sooner or later you going to use them.
Both ArrayList and LinkedList implements List interface so both of them are ordered by index and dynamically update its size

The difference is in the underlying implementation of these classes. ArrayList under the hood is simply an array and when you do

List a = new ArrayList();

then the add method creates an array and add 4 to its 1st position

later on if you do


then the add method creates another array of size = previous size + 1 and copy over the old values and write 5 to the 2nd position

However, LinkedList is all about pointers. It keeps a reference to the next element as well as the reference to the previous element (if it is doubly linked default it is singly linked list)

Doubly linked list are useful if you want to access the previous element from the current position rather than iterating it forward until you wrap back to the previous element

It is better to use Linked List over Array List if your code requires lot of insertion and deletions. Please see this link and hope you find it helpful