More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Design - Interview Questions and Answers for 'Abs' - 26 question(s) found - Order By Newest
Very frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory.
x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object.
Sample code:
String x = new String("str");
String y = new String("str");
System.out.println(x == y); // prints false
System.out.println(x.equals(y)); // prints true
Ans. Abstract classes can have both abstract methods ( method declarations ) as well as concrete methods ( inherited to the derived classes ) whereas Interfaces can only have abstract methods ( method declarations ).
A class can extend single abstract class whereas it can implement multiple interfaces.
Help us improve. Please let us know the company, where you were asked this question :
Ans. It is a Design Pattern that facilitates loose coupling by sending the dependency information ( object references of dependent object ) while building the state of the object. Objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally and hence provide better flexibility.
Help us improve. Please let us know the company, where you were asked this question :
Ans. MVC is a Design Pattern that facilititates loose coupling by segregating responsibilities in a Web application
1. Controller receives the requests and handles overall control of the request
2. Model holds majority of the Business logic, and
3. View comprise of the view objects and GUI component
Help us improve. Please let us know the company, where you were asked this question :
Ans. Factory Pattern deals with creation of objects delegated to a separate factory class whereas Abstract Factory patterns works around a super-factory which creates other factories.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Factory is a creational design pattern whereas Strategy is behavioral design pattern. Factory revolves around the creation of object at runtime whereas Strategy or Policy revolves around the decision at runtime.
Help us improve. Please let us know the company, where you were asked this question :
Q8. If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ?
1. Insert into the DB Table. If exception occurs, update the existing record. 2. Check if the record exists and update it if it exists, If not insert a new record.
Ans. In first case, there would be 2 DB calls in worst case and 1 in best case. In 2nd approach there will be always 2 DB calls.
Decision on the approach should depend on the following considerations -
1. How costly is the call to DB ? Are we using indices , hibernate etc
If calls to DB are costly , 1st approach should be the choice.
2. Exception Book keeping load upon exception.
The benefit of saving 1st call in approach 1 should be bigger than the Book keeping for the exception.
3. Probability of the exception in first apparoach.
If the DB Table is almost empty, it makes sense to follow Approach 1 as majority of the 1st calls will pass through without exception.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  database   insert-update   db exceution plan   db strategy   design   architecture   technical lead
Very frequently asked. Usually followed by questions related to private constructor and synchronized access. Frequently asked in JPMorgan and TCS (Based on 2 feedback)
Ans. It make sense only if we intend to modify either of the object and would like to preserve original state in other. Otherwise we can reuse the original object by making it singleton.
Help us improve. Please let us know the company, where you were asked this question :
Ans. AWS Services - CloudFront for distribution / caching, EC2 for computing, EBS for block storage , S3 for object storage , RDS for database , Kinesis for streaming , CloudWatch for monitoring.
Technologies - Java for back end with Spring Boot , Angular , RxJs for front end .
Architecture - Service Oriented. Multi layer.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Factory Design Patterns is the pattern that recommends creation of separate Factory Object for creation of other object.
So its like saying - If you want to create an object of ClassA, Talk to FactoryObject ( which is an object of FactoryClass ). FactoryObject in itself encapsulates the inputs and logic required to make the decision regarding the creation and construction of object.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Both are creational design patterns but singleton facilitates in creation and reuse of single object whereas Factory deals with creation of multiple objects.
Help us improve. Please let us know the company, where you were asked this question :
Ans. We can have 2 entities i.e EMPLOYEE and ADDRESS and can have a relationship Table , EMPLOYEE_ADDRESS having one to may relationship between the two.
Help us improve. Please let us know the company, where you were asked this question :
Ans. We initialize two variables first and second to INT_MIN as,
first = second = INT_MIN
then Start traversing the array,
If the current element in array say arr[i] is greater
than first. Then update first and second as,
second = first
first = arr[i]
If the current element is in between first and second,
then update second to store the value of current variable as
second = arr[i]
then Return the value stored in second.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Broad question, but if the company need velocity, think about use a NO SQL instead of regular SQL databases.
Also prefers materialized views instead of joins to fetch data quickly.
Regarding the database design, there are very good design tools for professional database (to develop proper indexes and good database design) one of the best is QuickDBD
Help us improve. Please let us know the company, where you were asked this question :