These are tried and tested questions with answers that an Interview tries to put a Java Back-end Engineer into. Feel free to comment your views and discuss each question in the comments section:-
Its one of my fav question that I like to ask to a fresher or an entry level engineer. If the interviewee says its a programming language he’s already inclined towards rejection form my side.
However the correct answer is that Java is a programming language along with a runtime environment which is platform independent. By platform independent I mean that Java code complied on one platform say Linux can easily run on another platform like Windows.
equals() is used to determine whether two objects are meaningfully the same or not. Whereas hashcode() is used to group various objects into a finite number of sections.
No. Two nonequal objects can also have the same hashcode. However, if two objects are equal then they should have the same hashcode. And it depends on how we have overridden the hashcode method
the final keyword is a way of suggesting due compiler that this resource ie class/ method/ reference cannot be modified further.
their use at various levels is as follows:-
- class level:- if used at class level it suggests the compiler that this class cannot be sub-classed further.
- method level:- if used at one method level it restricts the compiler for allowing that particular method to be overridden in any of the subclasses
- reference level:- if used at the reference level it restricts the compiler for allowing the new keyword from being called at that reference again.
Exceptions in java are basically classified into two categories:- Checked and unchecked. Their usage is as follows:-
1) Checked Exceptions:-These are the exceptions for which we can do something at the time of writing our code i. e. at compile time. For e. g. using try-catch blocks or throws clause
2) Unchecked Exceptions:- These are those exceptions that we cannot handle at the time of writing our code i. e. at compile time. The appropriate thing that we can do is to place checks to ensure these exceptions do not occur in the first place for e.g. placing null checks to avoid NullPointerException.
No. If we want to see the latest value every time we should synchronize our reads and writes by either using the synchronize keyword that java offers or synchronizing the getters and setters beer that variable.
We can also make that variable volatile.
No, we can’t throw broader exceptions while overriding methods. Reason being that it would break the polymorphic behavior of parent-child classes.
No, we can’t throw broader exceptions while overriding methods. Reason being that it would break the polymorphic behavior of parent-child classes.
JUnit is a unit testing library inbuilt in Java.
JUnit serve the following purposes:-
- They establish one contract for your classes
- They help you test the key business functionality before actually entering the integration phase
- They help in over camming the commonly occurring exceptions by fallowing a fail fast approach.
JUnit is a unit testing library inbuilt in Java.
JUnit serve the following purposes:-
- They establish one contract for your classes
- They help you test the key business functionality before actually entering the integration phase
- They help in over camming the commonly occurring exceptions by fallowing a fail fast approach.
In test-driven development, we first write JUNIT test cases for the classes/methods that we are designing before actually writing the implementation of our classes/ methods. So, initially, all the test cases are failing, we then continue to add implementations to make test cases pass one by one thereby completing our development when all the test cases pass.
A crisp answer to this question is, the addresses of the references is passed by value. So its kind of amalgamation between the two.
- Memory is divided into stack and heap.
- Stack is further subdivided into per thread stack.
- Variables local to the thread live on the stack as they need not be shared with any other thread.
- Heap is the common place where object live so that they can be share amogst different threads each having its own stack.
- For concurrent updation of objects in different threads we must synchronise before accessing the objects
- Streams: – the core benefit that streams offer is that streams are inherently lazy. Meaning that the iteration does not actually start until are iterable value is actually required. Another benefit is that it makes its own code a bit cleaner. Also, parallel streams help us leverage multiprocessor capability.
Lambdas: – lambda expressions are basically anonymous functions. The benefit of using them is that if a method is to be used only once, replacing it with lambda expression will move over to implementations where they are actually called.
Optionals:- optional are introduced to provide null safety. We generally wrap the nullable values is optional so at the time of accessing them, the caller is reminded to check if value is present or not.
Method reference:- introduction of method reference enables us to pass methods as arguments. This feature was introduced to compete with python.
-
the solid principle provides us with a guideline for designing classes.
The single responsibility:-A class should only partake in one responsibility.
Open closed:- classes should be open for enhancement but closed for modification.
Liskov’s substitution: objects of a superclass shall be replaceable with objects of its subclasses without breaking the application
Interface segregation:- Interfaces should be designed such that they can be segregated into one common interface.
Dependency injection:- classes should not be instantiating their dependencies themselves. This task should be handed over to a container class.
-
Our databases should be designed such that they possess their characteristics: –
Atomicity:- all the writes to a database should complete in one go.
Consistency: – any changes once made should not get lost.
Isolation:- all the writes should operate independently of each other.
Dependability:- Data fetched from the database should be correct and error-free.
-
Array List is used for faster random access and LinkedList is used for faster removal from the middle of the list.
It抯 really a great and useful piece of information. I am glad that you shared this useful information with us. Please keep us up to date like this. Thank you for sharing.
I was wondering if you ever thought of changing the structure of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?
This design is incredible! You definitely know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really loved what you had to say, and more than that, how you presented it. Too cool!
I am curious to find out what blog platform you happen to be using? I’m experiencing some small security issues with my latest blog and I’d like to find something more risk-free. Do you have any recommendations?
Feel free to contact us at spstechconsulting@gmail.com
F*ckin?tremendous issues here. I抦 very happy to peer your article. Thank you a lot and i’m taking a look forward to contact you. Will you kindly drop me a e-mail?
I must point out my appreciation for your generosity in support of people that really need help on your theme. Your personal commitment to getting the solution across appears to be pretty advantageous and have specifically helped men and women just like me to reach their ambitions. Your own helpful tutorial can mean a great deal a person like me and further more to my peers. Thanks a lot; from each one of us.
I have been surfing online more than three hours today, yet I never found any interesting article like yours. It抯 pretty worth enough for me. Personally, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before.
Can I just say what a aid to find someone who truly is aware of what theyre speaking about on the internet. You positively know the right way to carry an issue to light and make it important. More folks have to read this and understand this facet of the story. I cant consider youre no more widespread because you definitely have the gift.
Woah! I’m really enjoying the template/theme of this site. It’s simple, yet effective. A lot of times it’s hard to get that “perfect balance” between superb usability and visual appearance. I must say that you’ve done a very good job with this. Also, the blog loads extremely quick for me on Chrome. Excellent Blog!
I was wondering if you ever thought of changing the page layout of
your website? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with it better.
Youve got an awful lot of text for only having 1 or two pictures.
Maybe you could space it out better?
WOW just what I was looking for. Came here by searching for website
Thanks. Do join our mailing list for frequent updates. Comming soon!
My brother recommended I would possibly like this website.
He used to be totally right. This submit actually made my
day. You can not imagine just how much time I had spent for this
information! Thanks!
Best views i have ever seen !