Interview Questions and Answers - Order By Newest Q1921. Explain inner beans in Spring. Spring
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  spring  spring beans   spring inner beans Q1922. What are some limitations or dis advantages of Auto Wiring ? Spring
Ans. Autowiring a class of the same type throws an exception.
We can user @Qualifier to overcome this.
Autowiring cannot be used for primitives. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring  autowiring  spring auto wiring Q1923. What are the types of transaction management supported by Spring ? Spring
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  spring  spring transaction management Q1924. What are the different ORMs supported by Spring ? Spring
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  spring orm Q1925. What are the different types of advices in AOP ? Spring
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  spring app  spring  aspect oriented programming Q1926. What is weaving in Spring ? Spring
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  Spring Q1927. What is the use of upcasting in Java ? Core Java
Ans. Interfacing
Car extends Vehicle
Car car = new Car();
// now you need to call an API changeTires() which can change tires for all Vehicle Types and accepts argument of type Vehicle and hence you will have to upcast it
changeTires((Vehicle)car);
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  upcasting  type casting Q1928. Why do we pass an array of strings to main method ? Core Java
Ans. Array of strings in the main method are the list of arguments or parameters which are sent to the application / program. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  main method   main method string array argument Q1929. In Java, what is the closest thing to pointers? Core Java
Ans. References.
Unlike pointers in C , Java references are strongly typed and we cannot do pointer arithmetics with them. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  pointers  pointers in java  references Asked in 1 Companies Q1930. In Java, would you like to see an explicit destructor? Core Java
Ans. Yes , a gc method to explicitly call garbage collection immediately on the object. It will provide better flexibility over application that require optimal usage of memory. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  destructor  garbage collection Asked in 1 Companies expert Q1931. How to calculate lcm of two numbers ? Core Java
This question was recently asked at 'HCL Tech'.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  coding  code Asked in 1 Companies Q1932. Write a Program to find age by birth date ? Core Java
Ans. LocalDate today = LocalDate.now();
LocalDate birthday = LocalDate.of(1960, Month.JANUARY, 1);
Period p = Period.between(birthday, today); //Now access the values as below
System.out.println(period.getDays());
System.out.println(period.getMonths());
System.out.println(period.getYears()); Sample Code for LocalDate Sample Code for Period Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  coding  code  date  LocalDate  Period Asked in 1 Companies Q1933. What is a session bean ? Java EE
This question was recently asked at 'BirlaSoft'.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  session bean   java bean Asked in 1 Companies Q1934. Design a class diagram for a farm. Design
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  class diagram   design Q1935. Explain Inheritance and Polymorphism. Core Java
Ans. Getting parent class object properties into child class is called Inheritance.
The process of representing one form into multiple forms is called polymorphism. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  inheritance  object oriented programming (oops)  oops concepts  polymorphism  object oriented programming (oops)  oops concepts Asked in 1 Companies Basic   frequent Q1936. What is the difference between access and error log ? Logging
Ans. We log each access to the application resource within access logs, something like
"GET / HTTP/1.0" 200 113 "-" "Mozilla/5.0 zgrab/0.x" "-"
We log only error / warn messages within error logs, something like
ERROR 123#0: *19 connect() failed Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  logging  access log  error log Q1937. If Table A has 100 records and Table B has 50 records , how many records will the equi join of Table generate ? SQL
Ans. It depends on the join condition. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  equi join  sql join  database  sql Q1938. If Table A has 100 records and Table B has 50 records , how many records will the left join of Table A with Table B generate ? SQL
Ans. 100 records Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql  sql joins   left join Q1939. If Table A has 100 records and Table B has 50 records , how many records will the right join of Table A with Table B generate ? SQL
Ans. 50 records Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql  sql joins   right join Q1940. If Table A has 0 records and Table B has 50 records , how many records will the equi join of Table generate ? SQL
Ans. 0 records Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql  sql joins   equi join Q1941. What will be the output of following code
class TestMain {
public static void main(String[] args) {
String s1 = "ravi";
String s2 = new String("ravi");
Integer i = 10;
Integer a1 = new Integer("10");
System.out.println(s1 == s1);
System.out.println(i == a1);
}
} Core Java
Ans. false
false Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  object equality  ==  coding  code Asked in 1 Companies Q1942. Will the following code compile ?
final HashMap hm = new HashMap();
hm.put("Ravi", 221); Core Java
Ans. Yes, it will compile without error. final in this context means that the reference hm cannot be assigned to a new hash map but didn't restrict from changing the state of collection already held by hm. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  final  final variable Asked in 1 Companies Q1943. Explain Java 8 concurrency mechanism. Core Java
This question was recently asked at 'IBM'.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  synchronization  concurrency  java 8  java8 Asked in 1 Companies Q1944. What is the difference between being final and being immutable ? Are string final or immutable in Java ? Core Java
Ans. Being final in the sense of objects or object reference means that the reference cannot be reassigned to a different object whereas being immutable means that the object contents cannot be changed.
Strings in Java are immutable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  string  immutable  immutability  final vs immutable  immutabilityAns. Graph contain cycles whereas Trees cannot. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  graph  trees  data structures  tree vs graph Q1946. What does the following initialization mean ?
ArrayList<LinkedList> traversalPaths = new ArrayList<LinkedList>();
What could be the use of such a collection. Core Java
Ans. Initialize an ArrayList that will hold LinkedLists i.e every element of the arraylist will be a linked list.
Such collection could be used in algorithms that require first random access and then sequential traversal. For example - Storing traversal paths for a graph wherein we can start from any vertex. Implementing dictionary with each arraylist element holding staring with character and then linked list holding duplicate words. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections  linkedlist  arraylist Q1947. What will be the output upon executing main method
public class Graph {
private static Multimap<Integer,Integer> adjacentDirectedNodesMap = ArrayListMultimap.create();
Graph(){
adjacentDirectedNodesMap.put(1, 2);
adjacentDirectedNodesMap.put(1, 3);
adjacentDirectedNodesMap.put(1, 4);
adjacentDirectedNodesMap.put(3, 5);
adjacentDirectedNodesMap.put(4, 5);
}
public static void main(String[] args){
ArrayList visited = new ArrayList();
Integer startNode = 1;
for(Integer adjacentNodes: adjacentDirectedNodesMap.get(startNode)){
System.out.println(adjacentNodes);
}
}
} Core Java
Ans. Nothing as we haven't yet created an instance and hence adjacentDirectedNodesMap won't be initialized with any value and hence is empty. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  constructor Q1948. Given the list of adjacent nodes, What will be the Breadth First path
1 -> 2
1 -> 3
1 -> 6
2 -> 4
3 -> 5
Algorithm
Ans. 1 -> 2 -> 3 -> 6 -> 4 - > 5 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  breadth first traversal  graph traversal Q1949. Given the list of adjacent nodes, What will be the Depth First path
1 -> 2
1 -> 3
1 -> 6
2 -> 4
3 -> 5 Algorithm
Ans. 1 -> 2 -> 4 -> 3 -> 5 -> 6 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  depth first traversal  graph traversal Q1950. What will happen in a graph traversal if we don't have a check for cycle Algorithm
Ans. It will result in never ending loop Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  graph traversal