Friday, 27 September 2019

Citi Corp Java Interview Questions

CitiCorp Interview Questions
1. Variable used in Threading (say t1 works on Map, t2 should work after t1 finishes)
2. Circular Linked List. how to check if a list is circular?
3. What is Hashing, what's a bucket in hashing?
4. authentication in Web Servies
5. Get Nth employee salary in Oracle.  
6. Explain all the guarantees about the use of volatile keyword in the Java language from version 1.5  
7. Sort a array in such a way that the duplicates are also in
for ex
2 arrays
0 1 3 5
1 2 3 4
output should be
01123345
9.  spring we use Initialization Bean interface

10, Discuss method overriding in Java?
11. Discuss internals of a Hashmap? What is Role of equals() and hashcode() method in Object class? What will be behavior if we override hashcode() method to always return 1?
Solution discussed here
What is difference between Future and Callable interface in Java?
When should I use StringBuilder class in a program?
Tell me about your understanding of Executor Framework. How is it different from Fork Join Framework?
What is a Immutable Class? How does it help in writing scalable applications?
What is thread safety? How do you achieve it?
How will you handle ConcurrentModificationException?
What is difference between poll() and remove() method of an Queue?
What is difference between fail-fast and fail-safe iterators?
How are Concurrent Collections different from Synchronized collections?
What is difference between Vector and ArrayList?
What is difference between HasSet and Hashmap?
What is CopyOnWriteArrayList, how it is different than ArrayList and Vector?
When to use serialization vs externalizable interface?
Design Problems
How do you pass a job from Thread 1 to Thread 2 to Thread 3?
How will you implement a Queue in Java?
Discuss Singleton and Decorator Design Pattern. Discuss the practical usage of these design patterns. How to make singleton class thread safe?
How will you implement pagination in a web application? What is difference between Factory and Abstract Factory Design Pattern?
You have array of n size having numbers between 1 to 100. you need to provide algorithm for sorting array with BigO(n) iteration.
How will you implement your own Binary Tree in Java?
There is a very big text file containing words? How would you read & process it to print the below output.
Print the top ten ranked distinct words.
Print the occurrence of the each alphabet in this file consider that the file can not fit into main memory of computer.
How will you design your custom Connection Pool in Java?
Explain Types of db indexes.
What is LRU Cache
What methods you override in java.lang.Object class
What is Hashing how to implement custom hashing?

Thursday, 26 September 2019

Accenture interview questions for 4 year experience

Where java uses encapsulation
What is polymorphism
Explain system.out.println
How JVM works
How to manage outofmemoryerror
How to handle error in Java
What's is xMS and xmx in Java in case of 2 GB RAM
What is default heap size
Why segregation is there in error code of webservices
Which are required to handle
Difference between abstraction and interface
Why to use abs where to use Interface
What is DI
What is connection between di and interface
@autowired
How to connect to multiple database in hibernate
What is threadsafe in hibernate
How to handle exception
Try with resources closing
Where to use finally
How to map custom exception
What is index
Which Algo index uses
How does it works
Differ between primary key and unique key
How to check db performance
What is DI
How to configure Jenkins
Retrospective call in agile
How to manage a team
Project deployment cycle

Sunday, 22 September 2019

404 error accessing tomcat

Hi You might get tomcate 404 error when accessing localhost:8080

what option you can use here is


Solution

Go to server configuration


Go to Server location and select

"Use Tomcat Installation" This should resolve you error.

Friday, 20 September 2019

SAS PUNE JAVA INTERVIEW QUESTIONS

1. How to delete multiple data using Rest API?

2. What is aggregation, Inheritance and Composition give example?

3. What do you know about OOAD, SAS Analysis and BI tools?

4. What is a servlet?

5. What is Hibernate?

6. What is Spring?

7. Tell us about Spring Workflow?

Thursday, 19 September 2019

Integrating Java Web application with Maximo using Rest API Jersey

Steps
  1. Setup Jersey.
  2. Create an HTML page with workorder fields.
  3. Create a Submit button and call rest servlet.
  4. Pass those values collection from workorder fileds to servlet.
  5. Post the data to Maximo Rest Service.

Maximo Automation Script with Ldap

Hi Today we are going to connect to LDAP and query Ldap's data using Maximo Automation Script


Steps:- 
1. Define Ldap Attributes
2. Create a hashtable and put those attributes
3. Create a Context
4. Create a Search Control
5. Search using Context and Search Control
6. Loop through results and get required ldap attribute using criteria defined.

***************************************************************************

from javax.naming import *
from java.util import *
from javax.naming.directory import *
from psdi.mbo import SqlFormat

//Step 1 
print "Starting Ldap querying from Maximo"

ldapurl="ldap:serverurl:port"
ldapuser="XXXX"
ldappassword="XXXX"
ldapbasedn="DC=something,DC=com"


//Step 2
ldaptable=Hashtable()
ldaptable.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")
ldaptable.put(Context.PROVIDER_URL, ldapurl)
ldaptable.put(Context.SECURITY_AUTHENTICATION, "simple")
ldaptable.put(Context.SECURITY_PRINCIPAL,ldapuser)
ldaptable.put(Context.SECURITY_CREDENTIALS,ldappassword)

//Step 3

ctx =InitialDirContext(ldaptable) //Step4srch =SearchControls()
srch.setSearchScope(SearchControls.SUBTREE_SCOPE) //Step 6//To get email id of a person with person id Adam results=ctx.search(ldapbasedn,"Adam",srch) allattributes=results.getattributes() emailed=allattributes.get("emailed")

Tuesday, 17 September 2019

Call one automation script from another


One Automation Script with Multiple Launch Point

Steps:-

1. For doing this create a autoscript and define a lauch point.
2. Create a new launchpoint and instead of new script use existing script.


Launch Points and Variables in Automation Script


Tips for automation scripts

1. Use functions .

2. Write script in some editor or ide like eclipse to notepad++.

3. Use preferred language as Jython.

4. Put print statement or alert while developing to see result.

export data using automation script

Call automation script from an escalation or an action and use following code

server=MXSERVER.getMXSERVER();
userinfo=mbo.getthisMboSet().getUserInfo();
server.lookup("MIC").exportdata("MYPUBLISHCHN","MYEXTSYS","WHERECLAUSE",
useirnfo,-1);

Saturday, 14 September 2019

Unix Script to check if the file exist or not in folder

check_empty()
{
count=`ls \home\myfolder  | wc -l`
echo "count is "
echo "$count"
if test count -eq 0
then
   echo "Folder is empty"
   set err_msg = " FOLDER is empty..."
   echo $err_msg
   set sys_errs = "Y"
   exit 1
else
 echo "source folder is not empty folder"
fi
}
#**********************************************************************#
#** MAIN PROGRAM ******                                               
#**********************************************************************

check_empty()

Sending Email via Unix Script

to send email fromadmin@gmail.com to test@gmail.com we can use below short script

Mail.ksh

echo "Hi Sending you this email for information you that you are promoted now you become a father" | mailx -r _fromadmin@gmail.com -s "Email is generated and send to " test@gmail.com

Friday, 13 September 2019

What are modules of Spring


Getting Started with Spring JDBC

As we already know Spring based on 2 concept Dependency injection and Loose Coupling.

Getting Started with Spring Boot

As we already know Spring based on 2 concept Dependency injection and Loose Coupling.

Getting Started with Spring JPA


Getting Started with Spring AOP


Spring Framework Interview Questions

  1. What is Spring Framework?
  2. How Spring Framework inject Dependency?
  3. Why to inject dependency?
  4. What is IOC?
  5. What is difference between Bean factory container and ApplicationContext ?
  6.  How to setup Spring Framework?

What is IOC Container

It is a generic term used in Spring framework. Since we know Spring framework get control from class which needs dependency i.e Inverison of Control.

So all this happens in IOC Container.

Important IOC Container is ApplicationContext whose you we saw in Hello World Spring Framework Application.

Spring IOC container is very important as it will create object and configure them.

Types : 1. Bean Factory
            2. Application Context Container

What is Spring Framework


What is Spring Framework?


Spring is an open source framework and inversion of control for Java Application.

Spring is dependency injection framework.

In an enterprise application many classes depend on many classes where we can take leverage using this framework by injecting this dependency.


Example


consider we have a pizza process for creating pizza

Class Pizza{


Pizza(){


……………….Steps for Making Pizza
}

}


Lets say we have OnlineRestaurantService{

CookService cs=new CookService(Pizza)

}


Here we are passing pizza dependency to CookService in OnlineRestuarantService class.

In future we can pass Hotdog service also in place of Pizza.

So this all can be done by Spring Framework.


How can we let CookService know to inject pizza as dependency or Hotdog as dependency.

Well using annotations

2 popular annotations are @component and @Autwired

@component tells manage OnlineRestuarantService dependency and @autowired tells you need to look for Pizza dependency for Cook Service.

We will see all annotations in our Annotation Library blog for Spring framework.

Spring Error Spring cannot find bean xml configuration file org.springframework.beans.factory.BeanDefinitionStoreException

Error:  Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException

Well what you could do is put your bean xml file outside your package since frameword is looking it inside package.


path

ApplicationContext context = new ClassPathXmlApplicationContext("src/main/resources/beans.xml");



Else give path inside package example




Thursday, 12 September 2019

Getting Started with Spring Framework

Path for learning spring is

1. Spring framework.
2. Spring MVC
3. Spring Boot


Before beginning to what is Spring Framework we will learn what's the library to get all help from.

http://Spring.io it is a library where u can find all help documents, extensions related to spring.


What is Spring Framework?


Spring is an open source framework and inversion of control for Java Application.

Spring is dependency injection framework.

In an enterprise application many classes depend on many classes where we can take leverage using this framework by injecting this dependency.

How to setup Eclipse for Spring

1. Download Jdk 7 or 8.

2. Download Eclipse.

3. Download CommsApache jar https://commons.apache.org/logging/

4. Download Spring jars https://repo.spring.io/release/org/springframework/spring/5.0.0.RELEASE/
(download dist.zip)

5. Create a new Java Project and add CommsApache.jar and Spring jars.



Create Structure like below

Main class

package com.it.Hellow;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainClass {

 public static void main(String[] args) {
  ApplicationContext apc=new ClassPathXmlApplicationContext("Bean.xml");
  HelloWorld hellow=(HelloWorld)apc.getBean("hellowToWorld");
  hellow.getMessage();

 }
}


Hellow Class

package com.it.Hellow;
public class HelloWorld {
 private String message;
 public String getMessage() {
  System.out.println(message);
  return message;
 }
 public void setMessage(String message) {
  this.message = message;
 }
}


Bean.xml


<?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 = "hellowToWorld" class = "com.it.Hellow.HelloWorld">
      <property name = "message" value = "Hello World by Anil"/>
   </bean>
</beans>


Output on Running Main class as java application



What is happening here is your are creating a application context and passing it your bean xml name.

Then using that context your are telling what class to refer in that bean.xml using the ID defined in HellowWorld object. When Main class is loaded it pics up bean and supply message property with value Hello World by Anil and therefore prints o/p "hellow Wold by Anil".



What is bean

We can say its an object manage by Spring Framework.


What is Inversion of Control

It means we are giving control from class which needs dependency to Spring Framework.

Friday, 6 September 2019

Unix interview questions

1. What is architecture of Unix?

2. What is kernet?

3. how to check logs?

4. What are shells?

5. What you can do if you lost root user's password?

Unix Script for Practice

1. Write a script to connect to database and select data.

2. Write a script to pass server details and folder structure and schedule it run daily and send data over FTP it should be generic and reusable.

3. Write a script to monitor cron table in Unix and update it at run time.

Unix Crontask every 5 minutes Unix crontask run every 30 Minutes Unix crontasak Every day

Unix Crontask every 5 minutes Unix crontask run every 30 Minutes Unix crontasak Every day

For Scheduling unix Crontask to run every 5 minutes

*/5 * * * *

For 3 Minutes

*/30 * * * *

Format


Minute  Hour  Day of Month Month Year


/ per


* is every

- is range of value

so


* * * * * Is every minute

For 12 Hour 5 minutes in August (12:05)

5 0 * 8 *

For

At 10:00 on every day-of-week from Monday through Saturday.

0 10 * * 1-6



Thursday, 5 September 2019

Checking logs in Linux

Linux logs can be viewed /VAR/LOG directory this contains plain text text files.

You can view logs using ls command.

You can also view logs via dmesg, which prints the kernel ring buffer. It prints everything and sends you to the end of the file. From there, you can use the command dmesg | less to scroll through the output.

Linux checking users information

The /etc/passwd file contains a list of all the system user accounts, along with some basic configuration information about each user. 

Anil:Test@123:501:501:Anil Kumar:/home/anil:/bin/bash


Each entry has seven data fields, with each field separated by a colon. These fields are:

The username

The user's password

The user's system user ID number

The user's system group ID number

The user's full name

The user's default home directory

The user's default shell program

Tuesday, 3 September 2019

Hibernate error Initial SessionFactory creation failed.org.hibernate.HibernateException:

If you get this error

 Initial SessionFactory creation failed.org.hibernate.HibernateException the issue is you are using an old way to configure the file and hibernate can't determine the dialect what you can do is use new way to resolve this.