Interview Question and Answers | Search Coding Interview Questions - javasearch.buggybread.com
Javasearch.buggybread.com

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.
Label / Company      Label / Company / Text

   



Interview Questions and Answers

   next 30
Usually asked to entry level software developers.
  Q231. Write a program to swap two variables without using thirdCore Java
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


 Q232. Write a Program to print pattern like following

*
**
***
****
*****
*****
****
***
**
*
Core Java
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     


 Q233. What are the disadvantages of Hibernate over native APIs ?Hibernate
 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     


 Q234. If an Abstract class has only abstract methods, What's the difference between such a class and an interface ?Core Java
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


 Q235. Can we overload method as following ?

void method(int... x){};
void method(int[] x){};
Core Java
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


 Q236. What is the difference between single instance Web environment and Load Balanced Auto Scaling ? Amazon Web Services (AWS)
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


 Q237. What are the benefits of Dependency Injection or IOC ?Design
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


 Q238. If you need to consume messages from the queue faster, which approach will you recommend - batching or concurrency ?Design
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


 Q239. When we say final x = 10, is the reference final or the value ?Core Java
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


 Q240. What is the difference between Singleton and Prototype Bean scope in Spring ?Spring
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


 Q241. What is the difference between uninitialized values for primitive types and Wrapper classes ? Core Java
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     


 Q242. What is the use of Object class ?Core Java
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


 Q243. What is cloud computing ?Cloud Computing
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


 Q244. What are the services provided by AWS ?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     


 Q245. What are the problems one could face while working with serverless technologies like AWS Lambda ?Amazon Web Services (AWS)
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


 Q246. How Java 9 would help resolve NoClassDefFoundError through it's modularity ?Core Java
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


 Q247. What is the difference between subject and observable ?RxJava
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


 Q248. What are the disadvantages of Design Patterns ?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


 Q249. Differences between class not found exception and noclassdef found error ?Core Java
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


 Q250. serialization and deserialization of singleton classCore Java
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


 Q251. What is the cost of using Cloud Formation ?Amazon Web Services (AWS)
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


 Q252. How does AWS Lambda handle failure during event processing?Amazon Web Services (AWS)
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


 Q253. What does AMI include ?Amazon Web Services (AWS)
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


 Q254. Why is cloud infrastructure so powerful ?Cloud Computing
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)


 Q255. Which region is the latest and most popular in AWS ? What are the advantages and disadvantages of using this region ?Amazon Web Services (AWS)
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


 Q256. What are the advantage of having Edge Locations ?Amazon Web Services (AWS)
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


 Q257. What does effect , action and resource means with respect to AWS IAM policy ?Amazon Web Services (AWS)
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


 Q258. Within AWS S3, Why new files are available immediately for read operation but not the updates ? Amazon Web Services (AWS)
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


 Q259. What kind of Access Policy should be kept on S3 Buckets and Policy ?Amazon Web Services (AWS)
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


 Q260. How can we protect from accidental deletes in S3 ?Amazon Web Services (AWS)
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


previous 30   next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: