avi neo

Greenhorn
+ Follow
since Jun 25, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by avi neo

Thanks Paul, Ganesh for quick response.
I have recently come across the following code snippet to initialize an ArrayList during declaration of a List reference:



Can somebody help me understand how this piece of code works ?

Thanks in advance.
Thank you everyone for responding to the query.

Special thanks to Stephan for the step-by-step explanation.

Also thanks to Roel, Daniel and Henry for providing lot of information.
This is regarding the following code example provided in the section Increment and Decrement Operators of the book OCA Java 8 Study Guide by Boyarsky and Selikof :




From the subsequent explanation it looks like the processing is done from left to right in the following sequence:

  • x is increased by pre-increment operator (++x)
  • Then it is decreased by post-decrement operator (x--)
  • Finally it is decreased by pre-decrement operator (--x)



  • As mentioned in the book, post-unary operators have higher precedence than pre-unary operators.

    Shouldn't the sequence have been something as follows ?
  • x is decreased by post-decrement operator (x--)
  • Then it is increased by pre-increment operator (++x)
  • Finally it is decreased by pre-decrement operator (--x)



  • It would be great if somebody can clarify my doubt.


    Thanks in advance.

    Hi all,

    My question is why a non-abstract Parent Class can be extended by an abstract Child Class ?

    Take a look at the following code:-



    This code compiles fine and when it is executed it gives the following output:-
    Inside method1() AbstractTest

    Now in the class AbstractTest if the following three lines are commented :

    then the code gives compilation error:
    AbstractTest is not abstract and does not override abstract method method1() in Child

    In summary, a non-abstract parent class (Parent) can be extended by an abstract child class (Child). Now this means that all the methods decared in the parent class (method1()) get replaced by the corresponding method signatures in the abstract child class. Is there any specific reason why this is allowed in JAVA ?

    Thanks in advance.

    Avirup