Face to Face Java Interview Series 14

Face to Face Java Interview Series 14

This is Face to Face Java Interview Series 14 questions for Sr. Java Developer position in one of big credit card company in silicon valley California. Below are questions:

1. Apart from the IoC paradigm, from your own experience with Spring technologies, Can you tell me if Spring framework had actually helped you in application development ? If so, can you name few benefits ?
2. You have injected a bean B into a bean A via spring context xml. For the injection to work, do you still need a setter method in Bean A Java class that accepts Bean B as an argument ? Or is it just optional ?
3. If you are writing a standalone Java application (i.e not web), how do you load spring context file ?
4. Have you worked on Spring annotations ? If the answer is yes: Can you name few annotations and what is the purpose of each ?
5. How do you implement a singleton in Spring framework ?
6. If your java class is constantly accessing system resources like files and sockets and needs to keep them open for long time, if and how can you ensure that they are closed efficiently during the time when application is stopped ?
7. Have you worked on Java 5 and above versions ? If yes: Can you name some new API features since Java 5 ?
8. What is a Runtime exception ?. Can you name few ?
9. Can you name some patterns that you worked on ?
10. How do you specify heap size when launching a java program via command line ?
11. Have you worked on TrustStore and KeyStores in java ?. If so, how do you specify them via command line arguments ?
12. If you throw an Exception in the catch block, will the finally block will still be called ?
13) Can you write a sample bean context XML and show in your own way of how a bean injection can be done into another bean ?
14) Do you see any problems in the below bean declaration ?. If so, please name them:

<?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.1.xsd">
<bean id="myProcessor"  source="com.mycompany.MyCardProcessor.java" />
<component id="myCardValidator"  source="com.mycompany.MyCardValidator.java" />

</beans>

15) If lets say, this is a full and complete source listing of the LoginHandler java class. please pay attention to each and every line ?

package com.mycompany.security ;
public class LoginHandler {

    public String accountNumber;

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public void validateUser() {
        if (accountNumber != null) {
            System.out.println("Invoked validateUser method for "
                    + accountNumber);
        }
    }

    private LoginHandler() {
    }

}

Which of the statements below is true ?
a) Since validateUser is declared as public, any other Java class can create a new instance of LoginHandler and invoke the validateUser method
b) Only java classes in com.mycompany.security package can create an instance of LoginHandler and invoke the validateUser method
c) Only the derived classes (i.e those extending LoginHandler) can invoke the validateUser method
d) This code wont compile
e) LoginHandler in its present form cannot be instantiated or extended by another Java class

16) Write a java method that will take a String argument and print total number of occurences of each character in the input string.
For e.g: for a “hello world” input, the expected output is below

h – 1
e – 1
l – 3
o – 2
w – 1
r – 1
d – 1

Leave a Reply

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

I am not Robot *