Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers - Order By Newest | ||||
![]() ![]() | ||||
| ||||
Ans. 1. Query Optimization ( Query Rewriting , Prepared Statements ) 2. Restructuring Indexes. 3. DB Caching Tuning ( if using ORM ) 4. Identifying the problems ( if any ) with the ORM Strategy ( If using ORM ) | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Thread class holds the definition of start method ( This is the method that starts execution of new thread and then calls run method within the scope of new thread ). Interfaces don't hold any definition and so does runnable. So it makes it necessary the usage of Thread class , whatever implementation you choose. When your class extends the thread class, it carries the definition of start method from parent Thread class onto itself and hence new yourClass.start() helps starting a new thread and then executing run method in that new thread scope. When you implement runnable interface , you are just making it sure to the JVM that you have implemented the required method ( run() ) which the Thread start method will look for upon executing start method. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. List | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. Encapsulation | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. final | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Parameters are the variables that the method is expected to receive along with the method call. Arguments are the values which are passed on while calling the methods. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. There are 2 reasons for it. 1. Usage of Primitive types - Though Java provides classes for the primitive data types but as the usage of primitives is permissible, its considered unpure OOP's language. 2. Usage of Static members - Static members belong to the class and not objects and hence not considered fit for pure OOP's programming. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Constructors are used for initializing the object state once it is initialized and memory has been reserved for it. Destructor is used to de-allocate memory allocated by objects. There are no destructors in Java. Alternatively, Java provides Automatic garbage collection i.e automatically releasing the un-referenced memory. | ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. Deployment Descriptor which is usually web.xml is used to specify the classes, resources and configuration of the application and how the web server uses them to serve web requests.This file is usually added to WEB-INF folder and contains following * Servlet entries and url mapping * Plugins * Some info regarding authentication / filters * Landing Page * Event Handlers | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. HashTable has been deprecated. As an alternative, ConcurrentHashMap has been provided. It uses multiple buckets to store data and hence much better performance than HashTable. Moreover, there is already a raw type HashMap. The only difference between the HashTable and HashMap is that Hashtable is synchronized whereas HashMap is not. Most of the synchronized collections have been deprecated and their raw alternative have been presented as preferred.Synchronization has a cost. Using synchronized collection in places where there is no need of it leads to useless utilization of resources. As these collections are rarely used in a static context or shared among threads, Java might have thought it better to just provide the raw collection and let developers implement synchronization if he feels the need to do so. HashMap is now presented as the default and the preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable. Because of this, Java thought it right to deprecate the use of HashTable.' Synchronization has a cost. Using synchronized collection at a place where there is hardly any need of it would means useless utilization of resources. As these collections are rarely used in static context or shared among threads, Java might have thought it better to just provide the raw collection and let developer implement synchronization if he feels the need to do so. As HashMap has been presented as default and preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable, Java thought it right to deprecate the use of HashTable. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. 1. HashSet doesnt maintain its elements in any specific order and is all random whereas TreeSet maintains elements in natural order 9 order defined by the equals method of TreeSet element type ) 2. TreeSet doesnt allow null elements whereas HashMap does. 3. As TreeSet orders elements and is hence insertion is comparatively slower. 4. HashSet performs basic operations like add(), remove(), contains(), size() etc. in a constant size time. A TreeSet performs these operations at the order of log(n) time. 5. HashMap in Java internally backs a HashSet. A NavigableMap backs a TreeSet internally. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. [Open Ended Answer] Usually answered stating your keen interest in the role offered and challenges and opportunities the role offers. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Yes, That is possible class A { public static void main(String args[]){ if(System.out.printf("Hello World")==null){} } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Because of the life cycle requirement for different type of values in java. variables initialized and used in functions needs to be destructed with the execution of function and hence kept in stack. Same is applicable for the object references initialized within the method. If objects would have been created in stack, they wouldnt have been passed around across methods and hence they are created on heap. So anything that is required beyond the scope of a method or function is kept on heap which is usually garbage collected by Java. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. 1. Objects are serialized and not classes and hence Static variables are ignored. 2. Transient is an explicit declaration to ignore the variable during serialization and hence transient instance variables are ignored too. 3. Base class instance variables if the base class hasn't been declared serializable. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. First expects the argument as a string array whereas second expects variable number of string arguments or a string array. So we can call both by providing string array as an argument but second can be called with 0 to n string arguments which cannot be done for first. for example - We can call second method with any of following method(); method("Hello"); method("Hello","World"); method(new String[4]); | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Inner Class is a class that is nested within another class whereas sub class is a class that extends or inherit another class. Inner class can only be accessed using reference of outer class ( Class name , if inner class is static or object reference, if inner class is non static ) whereas Sub class is accessed directly. In terms of memory, inner class is stored just like another class having it's own body whereas sub class carries the body of parent class as well as it's own fields in memory. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. In Breadth first algorithm, all the adjacent nodes of the starting node is visited first and then the same rule is followed while moving inwards whereas In Depth first algorithm, all the nodes of a single traversal path are visited first till a cycle or an end is found. For example , given the following entries of adjacent nodes 1,2 1,3 1,6 2,4 2,5 3,6 The Breadth first path would be 1,2,3,6,4,5 and Depth first path would be 1,2,4,5,3,6 | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. No. It will result in a type mismatch error. Collection<Collection> collection = new LinkedList<Collection>(); is a valid initialization as collection being reference of "Collection" class can hold object of derived Class "LinkedList" due to runtime Polymorphism. Runtime polymorphism is not applicable to type arguments. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. With Collection classes , we cannot use primitive types. Moreover for any class using generic types, we cannot use primitive types. They add more functionality by means of additional methods. As their reference can be null , they offer consistent check for uninitialized state. They facilitate caching and reuse by means of constant Pools. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. We are not resizing the first array here but assigning the reference strArray to a new Array with size 5. So after line 2, We have 2 arrays in memory, one with size 2 and other with size 5 with strArray referring to second array with size 5. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. CloudFront for Static Media and cached content EC2 and EKS ( Docker ) for main application computing RDS and DynamoDB for Database Lambda ( computing ) for running back end cron jobs Kinesis for streaming and SQS for queuing CloudWatch for Monitoring CloudFormation for Infrastructure templating S3 for Object Storage | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. S3 Standard S3 IA - Infrequently Accessed S3 One Zone IA - One Zone only , Infrequently Accessed S3 Glacier - achieved S3 Standard is most expensive , Glacier is least expensive | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Storage Tier ( IA , Standard , Glacier etc ) Storage ( Volume of Data ) No of Requests Meta Data Data Transfer Speed acceleration through cache and Edge Location | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. EC2 - Time and Reservation , Instance Type ( Memory , Computation power ) S3 - Accessibility Frequency , Data Transfer , Storage Space CloudFront - Geography, No of Locations EBS - IOPS, Access Frequency | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Simple Weighted Latency Failover GeoLocation Multivalue | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. A VPC is devided into multiple subnets. Subnet in a particular VPC could be public or private. For Example - A particular account may have multiple vpc's for each of the business type. For each Business or VPC , One can have different subnets to cater to each department so that access across departments could be restricted. But still there could be identities that have control over different subnets. Moreover we could have multiple subnets for each department so as to have distinguished public and private networks having different types of applications ( public facing or internal consumption ) | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Simple Inner Class, Local Inner Class, Anonymous Inner Class, Static Nested Inner Class. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. List - Members are stored in sequence in memory and can be accessed through index. Set - There is no relevance of sequence and index. Sets doesn't contain duplicates whereas multiset can have duplicates. Map - Contains Key , Value pairs. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. Java doesn't support multiple inheritance. Interfaces does't facilitate inheritance and hence implementation of multiple interfaces doesn't make multiple inheritance. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() ![]() | ||||