vipul John

Ranch Hand
+ Follow
since Oct 14, 2010
Merit badge: grant badges
For More
India
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by vipul John

Welcome Sean Kane & Karl Matthias!
I just read an article on reference types like strong, weak , soft and phantom references. I want to know, will the developers in real time use these reference types and in what kind of applications.
In my whole experience I haven't used them and also code review team ever mentioned about it while reviewing code.
6 years ago
Local variables, in your case 'method' should be initialized with a value mandatory. Instance variables, if not initialized takes default values, but local variables don't.
6 years ago

salvin francis wrote:Default methods allow you to append more methods to your interface without breaking current systems.


providing default implementation is abstract class job, right?

My question is , are they doing abstract class job?  I understand they are introduced for Java 8 backward compatibility.
But going forward, how do they impact design of interfaces and abstract classes.
6 years ago


source: https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html

JavaTutorials wrote:Default methods enable you to add new functionality to the interfaces of your libraries and ensure binary compatibility with code written for older versions of those interfaces.




I assume the word in bold is backward.
6 years ago
Also, abstract classes define default behavior and implementing classes define specialized behavior. With the default methods in interfaces, how much does it impact interface, abstract class and specialized classes design.
6 years ago
I am reading an article on default methods in interface. I want to understand when to use abstract classes and interfaces.

The abstract class can define constructors. They are more structured and can have a state associated with them. While in contrast, default method can be implemented only in the terms of invoking other interface methods, with no reference to a particular implementation's state.

I did not understand the default method difference explained. Could any one help me understand.

Please also let me know when to use abstract classes and default methods in interfaces.
6 years ago
Hi All,

OCAJP - 1 book assessment test has below program. I did not understand how could parent access its private method when parent reference instantiated child object.



ouput is deer childCH false.

I am expecting deer childCH true. According to run-time polymorphism, child class hasHorns has to be invoked, right? Please let me know. Thanks.
Welcome Julien Vehent to code ranch.
6 years ago
One of my favourite books in java. I have learnt very good programming by reading Effective Java Third Edition book. Thanks Joshua
6 years ago

Kathir jeyap wrote:
I used the same code...However 500 error is returned and the page got redirected to the error page

I want the same page or window or dialog should be retained..

Please advise.



Why 500 is returned. Could you post the code you've written or the exception that is thrown?
7 years ago
you can use ModelAndView object. set the error message  and return ModelAndView object as response.

Please check below code. It helps.


write this piece of code inside @ControllerAdvice annotation class.
7 years ago