Face to Face Java Interview Series 54

Face to Face Java Interview Series 54

This is another face to face round of interview questions with BNP Paribas Jersey city office for Sr. Software developer position:

1st round:

1. Have you used JDBC drivers how many types of drivers are available and which you used?
2. You said type 4 (pure java driver) is faster than other 3 why its so
3. Have you use Oracle OCI driver (What is the difference between OCI and thin driver)
4. What is the difference between OCI and THIN driver connection with data source connection between java and oracle XE?
5. What pura java driver internally does to make connection to database (As you interviewer understandning Database is not java so how pure java connect to the DB which is not written in java)
6. What is connection pooling. How you decide what is the maximum/minimum number of pool to put into your configration
7. Let’s say I configure connection pooling to maximum 2000 connection what will happen. How connection pooling API check its maximum capacity
8. What in case if it works while increasing size connection pooling to 500. Then what is the difference between 50 conenction pool and 500 connection pool
9. What happens when I decide to use connetion pooling max and min both 5 (Will it be there any performance iss
10. Have you worked on the spring. What is scope of bean in the spring
11. Let’s say I have clustered environment with multiple server then how many instacne of singleton bean class will get created
12. Let’s say you have multiple JVM in clustered environment then how many instance of singleton bean will be created
13. What is is bean life cycle in spring
14. If I don’t want to initialize the bean in spring what we do – lazy-init=”true”
15. Spring default behavior for lazy-init – The default behavior for ApplicationContext implementations is to eagerly pre-instantiate all singleton beans at startup. Pre-instantiation means that an ApplicationContext will eagerly create and configure all of its singleton beans as part of its initialization process. Generally this is a good thing, because it means that any errors in the configuration or in the surrounding environment will be discovered immediately
16. How hibernate use transaction
17. Can we start multiple trasaction in one sesssion
18. Can we create multiple session inside single trasaction in hibernate
19. Let’s say we have two separate schema and you need to save data in it how will you do it in hibernate
20. Can we handle two database connection in one session factory
21. If let’s say you create two session factory the how will handle trasaction in both in one shot
22. Let’s say client is request account cahnge which need two database works how will you do it in hibernate
23. What are differnt types of inheritence mapping done in hibernate and which one you have used
24. If you are using table per hierarchy mapping how table will be distinguish the record with the table — discriminator subelement of class must be specified
25. What do you mean by lazy initialization in hibernate
26. What is equal and hashcode why this needs to be overridden
27. What is the difference between cluster and non-cluster index
28. What happend if we dont crate any cluster or non-cluster index in the database (Will inserting data will be slow as compare to where we have cluter and non-cluster index)
29. What is index and why we crate index. How data will be store in index

2nd round:

1. Have you use maven. What maven does
2. Let’s say you have remote reposity how you pull data to you local
3. If you want to skip test in maven what you do
4. If you are adding dependency in your project and let’s say you load spring 3.4 which has dependency with spring 3.0 so both will loded if you don’t want to load spring older veriosn in your project what you do
5. What maven install does
6. What is maven life cycle
7. How you distribute maven jar what is the command for this
8. How you export(Publish) newly created jar to the repository
9. What tools you have used for you continuos build
10. What type of configration you have with Jenkins so that it will build and deploy file automatically
11. What version control tool you used so far and which one best
12. How you serialize object in java
13. When you implement serializable interface eclipse will complain you to add serializatio version into the class, what is the use of it
14. Let’s say I have a class Employer with two attribute int i, String j and I don’t want this value serialize what we do
15. What is transient variable
15. Let’s say I have below class:

public class Employee {

private String iName;
private String jName;
private Department department;

public Employee(String iName, String jName, Department department) {
this.iName = iName;
this.jName = jName;
this.department = department;
}
}

What extra work we do to serialize Department object as well with the Employee class

16. What front end tool you have used
17. Have you used javascript
18. How many objects are there in javascript
19. What is AJAX and what is the use of it
20. What is the differnece between sychronous and Asynchronus call and how you define in AJAX call
21. What module you have used in AngularJS
23. What is differnece between AngularJS and JQuery
24. Have you used concurrent package
25. What are classes and interfacd are there in concurrent package and which one you have used so far
26. If you have to submit the task asychronousely and want to process all this in order. How we can achieve through multithreading
27. Where you have used multithreading in your project can you tell me in datails how you did it
28. What interfaces and classes you used for you multithreading programming
29. Why you use multithreading why not single threading
30. Who write SQL, Store precedure, trigger and function in you project
31. What is trigger where you have used it in your project
32. How many types of trigger are there

3rd round:

1. What is will output of below program and why:

public class MyCalculator implements Runnable {

	MyCalculators myCalculators;

	public MyCalculator(MyCalculators myCalculators) {
		this.myCalculators = myCalculators;
	}

	public static void main(String[] args) throws InterruptedException {

		Thread t1 = null;
		Thread t2 = null;

		t1 = new Thread(new MyCalculator(new MyCalculators(1)));
		t2 = new Thread(new MyCalculator(new MyCalculators(1)));

		t1.start();
		t2.start();

	}

	@Override
	public void run() {
		myCalculators.incretment();

	}

}

class MyCalculators {

	int i;

	public MyCalculators(int i) {
		this.i = i;
	}

	public void incretment() {
		i++;
		System.out.println("Value of i: " + i);
	}

}

2. What will be output of below program what’s wrong with it:

import java.util.HashSet;
import java.util.Set;

public class EmployeeTest {

	public static void main(String[] args) {

		Set<Employee> set = new HashSet<>();

		Employee employee = new Employee("Michael", "Jackson");
		set.add(employee);

		employee.setjName("Jordan");

		Employee employee2 = new Employee("Michael", "Jordan");
		set.add(employee2);

		for (Employee employee3 : set) {
			System.out.println(employee3.getiName() + " " + employee3.getjName());
		}

	}

}

class Employee {

	private String iName;
	private String jName;

	public Employee(String iName, String jName) {
		this.iName = iName;
		this.jName = jName;
	}

	public String getiName() {
		return iName;
	}

	public void setiName(String iName) {
		this.iName = iName;
	}

	public String getjName() {
		return jName;
	}

	public void setjName(String jName) {
		this.jName = jName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((iName == null) ? 0 : iName.hashCode());
		result = prime * result + ((jName == null) ? 0 : jName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (iName == null) {
			if (other.iName != null)
				return false;
		} else if (!iName.equals(other.iName))
			return false;
		if (jName == null) {
			if (other.jName != null)
				return false;
		} else if (!jName.equals(other.jName))
			return false;
		return true;
	}

}

interviewer gave hint: It will print below two times why:

Michael Jordan
Michael Jordan

If its printing two time then we are breakng object uniqueness of set why its so, how you will fix it.

Answer: We shouldn’t have to expose setter method also we should always keep class immutable

3. How you will write below to get the same output without overloading and overriding method:

abc(1,2) -> result 3
abc(1,2,3) -> result 6
abc(1,2,3,4) -> result 10

Answer:

public class ObjectArgumentTest {

	public static void main(String[] args) {

		System.out.println(addNumbers(1, 2));
		System.out.println(addNumbers(1, 2, 3));
		System.out.println(addNumbers(1, 2, 3,4));
	}

	public static int addNumbers(int... value) {

		int result = 0;
		for (int i : value) {
			result = result + i;
		}
		return result;
	}

}

4. How many types of DI are there in spring
5. What will be output of below spring app program:

Bean.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   <bean id="helloWorld" class="com.javahonk.HelloWorldBean">
       <property name="message" value="Hello World!"/>
       <property name="test" value="test"/>
   </bean>

</beans>
public class HelloWorldBean {
	
	private String message;
	private String test;
	
	public HelloWorldBean() {
		System.out.println("Default constructor");
	}	
	
	public HelloWorldBean(String message, String test) {
		this.message = message;
		this.test = test;
		System.out.println("Two argument constructor");
	}

	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
		System.out.println("setMessage called");
	}
	public String getTest() {
		return test;
	}
	public void setTest(String test) {
		this.test = test;
		System.out.println("setTest called");
	}
	 
}
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
	public static void main(String[] args) {
		
		ApplicationContext context = new ClassPathXmlApplicationContext("Bean.xml");
		//What will be output at this point
		
		HelloWorldBean obj = (HelloWorldBean) context.getBean("helloWorld");
		//What will be output at this point
		
	}
}

Output:

Default constructor
setMessage called
setTest called

Let’s say if we change lazy-init=”true” as below:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   <bean id="helloWorld" class="com.javahonk.HelloWorldBean" lazy-init="true">
       <property name="message" value="Hello World!"/>
       <property name="test" value="test"/>
   </bean>

</beans>

and comment below line then what will be output:

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
	public static void main(String[] args) {
		
		ApplicationContext context = new ClassPathXmlApplicationContext("Bean.xml");
		//What will be output at this point
		
		//HelloWorldBean obj = (HelloWorldBean) context.getBean("helloWorld");
		//What will be output at this point
		
	}
}

Answer: No output because lazy-int is true

4th round:

1. How Primebrokerage works and makes money?
2. How Shorting works?
3. Whats difference between trades and positions.
5. Tell me your previous prime brokerage/financial experience.
4. Write a Generic class implementation of a generic interface(e.g. List)
5. Custom class object to be used as Hashmap key. What is needed and how does equals & hashcode method work.
6. Web-Services: Asked to write a new JAX-WS web service, how exactly do you go about creating the WS? What will the classes look like. What will the project structure look like. where and how will you deploy it and how will the clients use your Webservice. Explain the entire end-to-end process. Write a Jax-ws service class which compare two strings and return if they are same or not.
7. Spring: How bean wiring in spring works. Different ways you can inject class property values in spring xml.
8. Given Classes with Inheritance in Hibernate, how will the DB table setup look.(e.g. Parent class Card. Child classes Debit Card & Credit Card)

Leave a Reply

Your email address will not be published. Required fields are marked *