Search Interview Questions | 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. |
|
| ||||
Interview Questions and Answers | ||||
Usually asked to entry level software developers. | ||||
| ||||
Ans. public static void main(String[] args) { int num1 = 1; int num2 = 2; num1 = num1^num2; num2 = num1^num2; num1 = num1^num2; System.out.print("num1 = " + num1 +", num2 = "+num2); } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  coding Asked in 37 Companies basic   frequent | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { for(int x=1;x<=5;x++){ for(int y=1;y<=x;y++){ System.out.print("*"); } System.out.println(""); } for(int x=5;x>=1;x--){ for(int y=1;y<=x;y++){ System.out.print("*"); } System.out.println(""); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
This question is still unanswered. Can you please provide an answer. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. Such a class still can have member elements which can be inherited and hence facilitate code reuse. Moreover Abstract class can have non final static elements whereas interfaces are only allowed to have static final elements. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  abstract class   interfaces Asked in 2 Companies Basic | ||||
| ||||
Ans. No. Because java internally treats var args as arrays and hence both method declarations will generate the same byte code and hence would result in ambiguity while determining call binding. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  var args  methods  functions   method declaration  scjp  ocjp | ||||
| ||||
Ans. Single instance means there is only 1 instance that will bear all the traffic load whereas Load balanced server means that there will be a cluster of servers that will host the application and load will be balanced distributed among them. Auto Scaling means that the number of instances will be expanded / shrunken based on the rule. Rule could be the traffic count , response time etc. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  load balancing  auto scaling  aws  elastic beanstalk | ||||
| ||||
Ans. Central place for configuring dependencies. No need to create object, container manage all this By using Run time polymorphism and association. Facilities development of framework / libraries by injecting implementation classes in the implementation code. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  dependency injection  IOC  inversion of control | ||||
| ||||
Ans. Each has it's own advantages Batching requires less resources but may result in loosing whole batch in case of failure whereas concurrency even though is little more expensive in terms of resources but would result in minimal loss in case of failure. In case messages are to be consumed in a particular order, batching them in that order and then consuming them makes better sense. if incoming messages are not continuous , it makes more sense to do concurrency as we need not wait for all messages to form a batch and flush. Though time sensitivity can be added but that would add unnecessary complexity. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  concurrency vs batching   concurrency  multithreading  batch | ||||
| ||||
Ans. final keyword have meaning only to referenced and not the value. It means that the specified reference cannot be dereferenced. It doesn't control the value assigned to the memory that's being referenced. This is the reason that final object references doesn't mean that the object is immutable but means that the reference cannot be changed to point to new object. In case of primitive types too, when we assign a reference to another, values are passed and not the object reference, and hence a new placeholder is created in memory with the same value. That is why final to that context means that you cannot change the assigned memory and there is no way we can have that memory place have another value. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  final keyword  final variables  references | ||||
| ||||
Ans. Prototype scope - A new object is created each time it is injected/looked up. It will use new SomeClass() each time. Singleton scope - It is the default scope. The same object is returned each time it is injected/looked up. Here it will instantiate one instance of SomeClass and then return it each time. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Spring beans  singleton bean scope  prototype bean scope Asked in 1 Companies | ||||
| ||||
Ans. When we create reference for primitive type, it's memory is allocated. So even if we don't assign any value to it, the default value is initialized. int x; // default value 0 initialized But for object references, it's different as references hold nothing till an object is assigned. Object obj; // contains null So all primitive types when declared , contains their respective default values on the basis of their type whereas all wrapper class References contains null irrespective of their types. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. 1. Default definition for some of the methods , like equals, hashcode etc that gets carried to all objects even if you don't define anything. But that default definition is kind of like assigning 0 to integer, it just provide a safe state , nothing much for comparison. 2. Places where you have no idea about what object you may receive and just want to perform out of 8 basic methods of object class, something like printing their string representation ( defined by their toString method ), or equality ( using their equals method ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  object class | ||||
| ||||
Ans. Cloud Computing is a way of using IT infrastructure with following traits - 1. On Demand Infrastructure 2. Broad Network Access 3. Resource Pooling 4. Rapid Elasticity 5. Measured Service | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  google cloud platform (GCP)  Amazon Web Services (AWS | ||||
| ||||
Ans. AWS provides various types of services like Computing ( EC2 , Lambda , EKS ), Storage ( S3, Glacier ), Database ( RDS , DynamoDB ), Streaming ( Kinesis ), Queue ( SQS ), Security and Access ( IAM ) etc. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. Warm up time for certain technologies like Java ( JVM Warmup ) Performance Size of Deployable ( Bigger size packaging should go in S3 ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  serverless technologies  aws lambda  aws serverless computing  amazon cloud serverless computing  amazon lambda Asked in 1 Companies | ||||
| ||||
Ans. Java 9 would provide an error at compile time if there are different modules with the same package mapped to the same class loader and hence would provide a compile time check for this issue. NoClassDefFoundError exists because of ambiguity at realtime because of multiple versions of same package / class exist. As Java 9 would provide a compile time check for it through clearly defined dependencies and exports and a check on duplicate packages being loaded by single class loader, it will fix the problem. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java 9  java 9 modules | ||||
| ||||
Ans. Subject has state, it keeps a list of observers. On the other hand, an Observable is really just a function that sets up observation. While Subjects are Observables, Subjects also implement an Observer interface. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  RxJava  Design  Design Pattern | ||||
| ||||
Ans. 1. Design patterns are abstraction heavy and hence sometimes creates memory and performance overheads. 2. Sometimes they create unnecessary complexity without much added advantage. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 1 Companies | ||||
| ||||
Ans. ClassNotFoundException is an exception that occurs when we try to load a class at run time using Class.forName() or loadClass() methods and mentioned classes are not found in the classpath. NoClassDefFoundError is an error that occurs when a particular class is present at compile time, but was missing at run time. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  exception handling  ClassNotFoundException  NoClassDefFoundError Asked in 1 Companies | ||||
| ||||
Ans. The problem with serialized singleton class is that whenever we deserialize it, it will create a new instance of the class. To overcome this scenario all we need to do is to provide the implementation of readResolve() method. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  singleton  serialization Asked in 1 Companies | ||||
| ||||
Ans. Cloud Formation does not have any additional cost but you are charged for the underlying resources it builds. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws cloud formation | ||||
| ||||
Ans. In AWS Lambda we can run a function in synchronous or asynchronous mode. In synchronous mode, if AWS Lambda function fails, then it will just give an exception to the calling application. In asynchronous mode, if AWS Lambda function fails then it will retry the same function at least 3 times.If AWS Lambda is running in response to an event in Amazon DynamoDB or Amazon Kinesis, then the event will be retried till the Lambda function succeeds or the data expires. In DynamoDB or Kinesis, AWS maintains data for at least 24 hours. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws lambda  aws serverless computing  amazon cloud serverless computing  amazon lambda | ||||
| ||||
Ans. A template for the instance. Launch permission decisions A block device mapping, when an instance is launched it determines the volumes to attach to that instances. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws ami  amazon ami | ||||
| ||||
Ans. Because it gives the ability to provision infrastructure on Demand with No contracts and strings attached. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Amazon Web Service (AWS)   Google Cloud Platform (GCP) | ||||
| ||||
Ans. US-East Virginia This is the oldest and most popular region. All new features are rolled first in this region and hence they are first available there. The downside is that because of experimentation with new services, unavailability time is quite high. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws region  aws us-east-1 | ||||
| ||||
Ans. It saves Network traffic and facilitates faster delivery by hosting bulk media and cached data near to client. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws edge locations | ||||
| ||||
Ans. effect means whether the effect of this Policy is to allow or deny, action means the type of action ( read , write ) and service, and resource is the resource where this should apply. For example - If we want to have a Policy of providing read access on S3 , effect will be "allow" action will be "s3:GetObject" resource will be "arn:aws:s3:::examplebucket/*" | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws iam  amazon iam | ||||
| ||||
Ans. Because new files will be fed from where ever they are first available but AWS have no way to identify which is the most updated version among the various regions. The updated version can only be assured once the replication to all availability zones is complete. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws s3  aws storage  amazon cloud storage  amazon s3 | ||||
| ||||
Ans. We should only allow access that's needed. So the security Policy should be as restrictive as possible. Buckets and Files should never be made public unless until they are needed it to be like that. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws s3  aws storage  amazon cloud storage  amazon s3 | ||||
| ||||
Ans. Versioning ( will create Delete marker ) MFA Delete ( authentication upon deletion ) Cross Region Replication ( Replicates aren't deleted ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  aws s3  aws storage  amazon cloud storage  amazon s3 | ||||