Interview Question

3 views
Skip to first unread message

Abhimanyu Singh

unread,
Mar 3, 2016, 6:21:04 AM3/3/16
to Technical Discussion
Recently I got these questions in interview. Please come with best answer :-

1. Core Java :-
    a >  Create a immutable class having mutable reference.
    b>   What are info be there in SerialVersionUUID in serilization
2 .Hibernate
    a> How a detached state be back in persistent state.
    b> Criteria  without session ( Detached criteria, Explain)
3. Spring
    a> what will be scope of a singleton bean which is referring to a bean which has prototype scope
    b> Singleton bean in multithread environment( Will get same object ? )
    c> Scenario where to use constructor-injection and setter-injection


Thanks,
Abhi.

Nishant

unread,
Mar 3, 2016, 7:06:02 AM3/3/16
to newidea_or...@googlegroups.com
1. It is basically a question to create an Immutable Class having a ref to a normal class. E.g

public class Neo {   //not immutable.
}

public final class Matrix {   //Immutable
   private final Neo neo;
 
}

Important thing to note here is ... iniside this Matrix Class, do everything to make Matrix IMMUtable like not having setters, constructors etc.
In addition to that ...
If the instance fields include references to mutable objects, don't allow those objects to be changed:
  • Don't provide methods that modify the mutable objects.
  • Don't share references to the mutable objects. Never store references to external, mutable objects passed to the constructor; if necessary, create copies, and store references to the copies. Similarly, create copies of your internal mutable objects when necessary to avoid returning the originals in your methods.
2.
It is used to control the versions of a Serializable Class, broadly speaking, if the class is Serialized and then Deserialized, then this number is used to verify that it is the same class that has been restored.
So, if you were to serialize a class with a SerialVersionUUID 2000 and then 10 days later the class version incremented to 2010, then the deserialization would fail throwing an Exception.


Spring, Hibernate.... I Hate Frameworks :P maybe SHail can help.

Regards,

NISHANT GUPTA / Master of Computer Applications
8050041001/ ccsC...@gmail.com

Facebook Twitter Google Plus Linkedin

-- If you could reason with Religious people, there would be no religion.


--
--
You received this message because you are subscribed to the Google
Groups "Technical Discussion" group.
To post to this group, send email to
newidea_or...@googlegroups.com
To unsubscribe from this group, send email to
newidea_or_techn...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/newidea_or_technical?hl=en

---
You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newidea_or_techn...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shailendra shail

unread,
Mar 3, 2016, 11:32:35 AM3/3/16
to Technical Discussion
2.a : 

3.a or 3.b:
Scope of singleton will be always singleton either it being used in prototype object or in multithread environment.

3.c 

--
Shailendra Kumar shail
Reply all
Reply to author
Forward
0 new messages