Interview Questions and Answers - Order By Newest Q991. What is Spring Security ? Spring
Ans. Spring Security is a powerful and highly customizable authentication and access control framework. It is the de facto standard for securing Spring-based applications. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 3 Companies Q992. Create a Class Bank with the methods to deposit and Withdraw ? Core Java
Ans. class Bank {
int balance;
Bank(){
balance = 0;
}
void deposit(int amount){
balance = balance amount;
}
int withdraw(int amount){
balance = balance - amount;
return balance;
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Basic Frequently asked in high end product companies. Ans. https://www.geeksforgeeks.org/lru-cache-implementation/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  cache  LRU cache  coding  code Asked in 10 Companies intermediate Q994. Explain your experience with Java, spring and web services? General
Ans. Have worked on Java 7 and Java 8, In Java 8 , Worked with streams , lambda expression and default methods.
Have worked on both Spring Mvc and Spring Boot, using Spring dependency injection, Rest services , AOP , JDBC and Hibernate integration.
Have worked on Rest services using Spring and Spring Boot. Have worked on SOAP web services too. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring  web services Asked in 1 Companies Q995. Will finally run if we have return statement and it exits the method early ? Core Java
Ans. finally will execute in all graceful situations - graceful executions as well as graceful exceptions. The only situation when finally block won't execute is when the app is abruptly stopped, killed or unplugged. Sample Code for finally Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  finally Intermediate Q996. Is there any relationship between Web.xml and Spring.xml ? Spring
Ans. No, there is no relationship between web.xml and spring.xml but you have to configure spring.xml in web.xml in order initialize beans when application starts up Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring  web.xml  spring.xml  deployment descriptor Asked in 1 Companies Q997. Why do you want to work here ? General
Ans. I believe that the company would provide a good ground for my career growth and learning. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q998. Why do you wan to stay in IT ? General
Ans. Coding , Science and Mathematics has always fascinated me. I have curious mindset that continuously look for solutions. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q999. How to make sure that no request are lost in client server application ? Solution
Ans. By keeping some sort of storage at the client side for each request and then matching it up against the response received to make sure that the request was well received.
A queue can be used for this purpose. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1000. Scale yourself on Java on the scale of 1 to 10 General
Ans. [Open Ended Answer]
The objective of the question is to check how efficient one is in the language so that appropriate level questions are asked. Don't tell too high number if you are being interviewed for a junior or mid level position as the interviewer may throw advance level questions. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 17 Companies Q1001. Is it mandatory to have a default constructor ? Core Java
Ans. No.
Default constructor is provided by compiler if no constructor is provided ( argument or no argument ) by us. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  constructor  default constructor Asked in 1 Companies Try 1 Question(s) Test Q1002. Which environment variables do we need to set in order to run Java programs? Core Java
Ans. PATH, CLASSPATH and JAVA_HOME Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  environment variables  path  classpath  java_home Asked in 3 Companies basic   frequent Q1003. Can an application have multiple main methods within different classes ? If yes, How will the app decide which one to be executed ? Core Java
Ans. Yes we can have a main method with string[] argument in every class of an application. When we execute an app we specify the starting point i.e the class that will get the control first and hence main method of that class gets executed. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  main method Asked in 3 Companies Q1004. Does importing a package imports all its sub packages too ? Core Java
Ans. No, but we can use wild card (*) to do so
For example -
import java.util.*
will import all packages with name starting with java.util Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  package   import packages Asked in 1 Companies basic Q1005. What is the default value of a declared object reference ? Core Java
Ans. Null Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  object reference  null Asked in 1 Companies basic Q1006. Is there a way to know size of an object in Java ? Core Java
Ans. No, Java doesn't have a sizeOf operator. In C / C++ , its required to determine how much memory allocation is required which is not the case with Java. Java handles memory allocation and deallocation intrinsically. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sizeOf  size of object  sizeOf operator Asked in 1 Companies   rare Q1007. What are the different ways to handle an exception ? Core Java
Ans. 1. Wrap the desired code in try block followed by a catch / finally to catch the exception
2. Declare the throws clause with exceptions that the code is expected to throw as an indication to the calling method to take care of it. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exception handling Asked in 4 Companies Try 1 Question(s) Test Q1008. How does Java handle integer overflows and underflows? Core Java
Ans. It uses those low order bytes of the result that can fit into the size of the type allowed by the operation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  integer  data types Asked in 1 Companies   rare Q1009. Is delete a keyword in Java ? Core Java
Ans. No, delete is not a keyword in Java. Destruction of objects is taken care by Java Garbage Collection mechanism. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  delete  keywords Asked in 1 Companies Ans. No exit is a method to exit execution of a program. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exit  keywords  exit a program Asked in 1 Companies Q1011. Who invokes a thread's run method ? Core Java
Ans. After a thread is started using a call to start method, JVM invokes the thread’s run method when the thread is initially executed. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  threads  thread run method Asked in 1 Companies Q1012. What kind of thread is garbage collection thread ? Core Java
Ans. Daemon thread Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  garbage collection intermediate Try 2 Question(s) TestAns. It's an object that reads from one stream and writes to another. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java io  io filter intermediate Q1014. Difference between shallow copy and object cloning ? Core Java
Ans. Shallow copy is one of the way for object cloning, other being deep copy. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  cloning  shallow copy  object cloning basic Q1015. how to access the methods of an inner class? Core Java
Ans. It depends on the type of inner class
To access non static inner class method
new OuterClass().new InnerClass().getMethod();
To access static method of static inner class
new OuterClass.InnerClass().getMethod(); Sample Code for inner class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  inner classes  nested aclasses Asked in 1 Companies Intermediate   frequent Q1016. Which memory segment holds String Pool in Java ? Core Java
Ans. String Pool resides in runtime constant Pool which is a part of Heap memory segment. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  string pool  memory management Expert   rare Q1017. Which Web and Application server is being used by your application ? Server
Ans. We are using Apache 2.3 and Tomcat 5.6 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  web server  application server  server Basic   frequent Q1018. How do you monitor your logs while investigating a high severity problem ? Support
Ans. We try to look for errors in the last n minutes when the issue occurred. If the issue is still occurring intermittently, We tail the logs for different application server instances to see the error snippets coming in the live logs. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  production support  unix  application logs Q1019. Have you done any sort of automation in your system monitoring tasks ? Support
Ans. Yes we have created System as well as Log monitoring scripts to keep track of exceptions. We are also using a tool that will inform the stake holders if an exceptional event occurs with the system. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  production support  system monitoring  log monitoring Q1020. Do you use command aliases while doing your work ? General
Ans. Yes , I have created many aliases and saved them within my .profile file so that the system loads them, the each time i logs onto the server. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix  command aliasis