HCL
HCL
HCL
ex-
my self a arun kumar basically i am from odisha, i have completed bca in 2013,after
completion of my studies i started my carrier by working in infogrid technology
that is there in banglore.
in this organization i am working as a java developer. i have been working in this
organisation since 3.4 years in one project named as AGD.
AGD stands for all goods details .its a erp domain project and our client for this
project from Europe.
the main objective of this project is a user can interact with suppliers through
online. user can get the status through online by mail about transpored product and
availability.
user check and view about historical data and user can generate his own
reports.this application is acts as a mediator between user and suplliers.
to implement this project we have been following agile mathodology.we are
developing code and transfer to tester.
afer completion of testing we deploy into live environment then another sprint wil
be released by our scrum master.
again we follow same. each sprint we takes around 15 to 20 days.and we conduct
daily one meeting roughly around 15 minutes about.
in this duration we talk about what we have done yesterday what problem we faced
and what we are going to do next.
in this project my roles and responsibilities are
implementing dao by using hibernate
developing modules by following spring mvc.
testing web serviece by using saop ui.
generate wsdl, creat wsdl.
debug the code and fixing bugs.
adding jars in pom.xml.
to make application to get better performation developing code by following several
design pattern like singleton, factory pattern, templet, abstarct factory pattern
etc.
implementing bussiness logics,analys bussiness requirement.
these are my roles and responsibilities in this projects
then the interviewer will start asking queations from core java to frameworks.
important topics in core java
1 strings
2oops
3collections include concurrent collections
4multi threading
5 several logical programs like, reversing, sorting, etc
hibernate
1 difference between get and load
3 difference between merge and saveOrUpate
4 caching
5 mappings one to many,many to one many to many
5 why sessionfactory is threadsafe
spring
1 why dependency injection came into the picture
2 what is ioc
3 what are the scopes
4 what is defference between beanfactory container and application container
5 flow of spring mvc
6 what are the view resolver
7 what is aop
8 what are the autowire modes
9 how to integrate with hibernate with spring, some times they ask you to write
down xml file
web services
what is rest
what is deffernce between soap and rest,
what are annotations in rest and their works
what is advantage from soap and disadvantage of soap
. friends these are commonly asked questions in regular interview. instead of by
chosing these question it is far better to learn in depth. but i am sure no
quetions can come out of nataraz sir's meterial.
and one.more thing when your going to interview dont go with heavy make up. just go
how your going daily to class
just go in cool mind. if you dont know any answer at all. say in positively i dont
know but if you give me a chance i will learn.
but sure when your going to attend intervie make sure that remember nataraz sir
classes. and go in cool mind.
ALL THE BEST GUYS
Today's CTS interview question
Technical Round:-
= = = = = = = = = = = = =
*Core-java
************
1 .Tell me the internal flow of Set implementation class with one example
ans:-Set Internally use Map so it doesn't allow duplicate
Map<Set<Obj>,String> m=new HashMap<>();
so whatever object u passed in set.add() method it will place in Map as a key as
per above.
3 . can we add duplicate in set and map if yes why write one code
ans: yes, we can add if u don't override equlas() and hashCode() then duplicate
will be allow in set and map also coz there is no element for comparing thats the
reason duplicate are allow..
class Employee{
int id;
String name;
public Employee(int id,String name){
this.id=id;
this.name=name;
}
@Override
//toString() method here
public static void main(String[] args){
Set<Employee> s=new Set<>();
s.add(new Employee(10,"Basant"));
s.add(new Employee(10,"Basant"));
sop(s);
}
}
4 . Read data from file find the duplicate word and count them and sort them in
desending order
public class ReadFileAndCount {
return wordMap;
}
@Override
public int compare(Entry<String, Integer> o1,
Entry<String, Integer> o2) {
return o2.getValue().compareTo(o1.getValue());
}
});
return mapList;
}
5 . where to use Comparable and where to use Comparator did you ever used in ur
project
ans: actually we are not using that interface in our project to sorting data..but i
have idea on it that we have to use Comparable if u want
to sort the object in collection in simple sorting order like assending or
desending if u want custom sorting then better to choose
Comparator.
6 . what is bubble sort can you write one programme. .?
public class ArraySort {
public static void main(String[] args) {
int[] arr = new int[] { 6, 8, 7, 4, 312, 78, 54, 9, 12, 100, 89, 74 };
7 . can I write try block single means without using try-catch or try-finally
ans: yes we can write .in java 1.7 there is one features try-with-resources by
which ur resourse stream will be closed automatically
8 . what is Executor framework
ans:Executor Framework is interduced in Concurrent package normaly if we want use
thread pool to achive reusability then we have to choose this one
9 . how many way we can create thread and which one best approach and why
ans:There are 4 way
1 . extends Thread
2 . implements Runnable
3. implements Cloneable
4 . using AnonymousThread
Preferable is 3rd one coz if you implements from Callable then see below
10 . jdk version u r using in ur project and why (be care on that question coz they
indirectly ask u the advantages of version or latest features added in New
version )
*Jdbc:-
**********
1 . difference between Statement and PreparedStatement
ans:Statement are use if we want to pass static querry or hardcoded value if we
uant to pass positional parameter/Runtime value
then better to use PreparedStatement and in Simple Statement there may be a chance
to get SQL Injection which we can be
Resolve by PreparedStatement
2.they give one db schema and ask me to retrieve data from DB by passing id
table:-
=====
id name
=============
101 Basant
104 Santosh
*Spring :-
**********
1.What is RowMapper when we have to use it write sample code not completely just
give sm hints with flow?
ans:See basically if we want to iterate complete entity from db then we have to use
RowMapper which are
Provided by Spring-Framework by which it can easily featch the data from db and it
follow call back
Mechanisim so it gives us Resultse as method parameter that we can simple get the
data by RS
3.if in my Spring bean configuration file I configure same bean with same id 2
times then what is the problem and how to resolve it (contender)
ans:we have to use one atribute in Spring-beans configuration file actualy i am not
able to remebere that word
properly coz we are using eclips id so but it like something Contender ...
??2.Dispatcher Servlet here act as a controller. Who only manage the request
processing. ..so it rcv the request and then forward request to HandlerMapping
??4.and 5 After finding controller Bean it process some operation and return MAV
object ..to Dispatcher Servlet
M:-model
A:-and
V:-view
??6 . Now after processing business operation response will be generated and it
should be display on browser otherwise how enduser know about response. ..so to
find appropriate view representer..Dispatcher Servlet call again ViewResolver.
.which helps to find appropriate jsp to display view
??7 . Then Dispatcher Servlet render data nd call that jsp which is identify by
ViewResolver to view response on browser. ..
6. How u handle Exception in ur Project just give some brief idea on it with
annotation
ans: ya to handle the exception we are creating separate Controller class
annotatted with @AdviceController and here we are
writting one method by passing the exception as parameter and annotated with method
@ExceptionHandler then from my controller
i have to pass same logical name which i already return from my adviceController
class
*Webservices :-
**************
1 . WSDL ,what are the elements and just explain the role of each section verbally
ans:
WSDL(Web service Description Language) actually it act as contract betwwen
provider and consumer and basically contain 5 section 1)Defination 2)types
3)Message 4)PortType 5)Binding 6)Service
Defination:-it act as a root element in XML it just specify the name
types:-it talks about each indivisual required input and output to my webservice
method
message:-it talks about exactly what my web-service method takes a parameter in
single unit
portType:-it talks about exact structure of your SEI(Service endPoint Interface)
Binding: talks about what is the protocol it used and which Message Exchanging
format it follows
service: it talks about address
2.what is Rest,
ans: Rest is a new architectureal style of develope the webservice or we can say
this one is the easyst way to our
complex business logic over the network with distrubuted technology with
interorporable manner
ans:Both are used to develope webservices only but the basic difference
1.In sopa base web-service we need to depends on Sopa protocol it act as a
transport protocol who support only Xml for transfer
but in rest it is support not xml it supports XML,JSON,PLAIN_TEXT also
2.Sopa development is complicated in comparision Rest coz we need to depends on
Multiple 3rd party vender
and procudure is varry from one implementation to anothe implementation
3.Sopa is not Message-Represention-Oriented but rest is M-R-O
4.for security and transaction Soap is Preferable..
4.Write one Resource method using Http method Post
5.which Response u provide to presentation layer and how to bind Json Response ?
ans: We are providing JSON Responce and it will bind through Angular js in UI.
6.Difference between @QuerryParm and @PathPatm which one best and where to use. ..
ans: QuerryParm is not mandatory to pass but if u want data is mandatory then
PathParm is Best
Core-Java----1 st round
===================
1.Interface & abstract class ?
ans: As per my project what we people are developed that will be hidden from user
so
for them it is abstraction otherwise explain Hari sir Bank Atm example
ans: Ya we implement all the concept in our project and Encapsulation we used in
Business Object or Model class
Inheritance and Polymorphisim we implement in Dao and Service Layer to make it
loosly coupled
5.To override all the method from super which keyword we have to use.and why
ans: implements keyword coz class+interface== always implements
7.Write 5 classes which u r develope in your project with fully qualified name ?
8.What are the exception u face in ur project development and how u resolve them
explain ?
ans:
1.NullPointerException:-Resolve by Remote Debugging
2.DataAccessException:-Enter the Column name properly this exception from DAO
3.ClassCastException:-Mentain Typecast or Generics properly
Second-Round(CoreJava+Spring)
===========================
1.What is abstraction
ans:Hide the implementation Provide only Functionality is called abstraction
2.How to create own immutable class write code
public class MyImmutable {
int no;
3.What is singletone ,In your project did u use singletone ,Where write code ?
ans:Singleton is object creation design pattern by which we can instantiate only
one instance
per one class per one jvm.
In my project i didn't use coz we are using Spring so every bean scope is
singleton
so we no need to make explicitly singleton.
<tx:advice id="manageEmployeeTxAdvice">
<tx:attributes>
<tx:method name="new*" read-only="false"
propagation="REQUIRED" />
<tx:method name="*" read-only="true" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
Plz explain Diff between GET and Load in hibernate . just highlight the point
When ever u have requirement that deleting row u dont need to get the comple object
just load proxy object with id u calln delete it
Deleting object from db
By get
Select * from emp and
Delete from emp where id=123
Load
Delete from emp where id =123
In load is best when deltion opration
When ever u have requirement that update / select row then get is best chioce...
need to get the comple object and then update with new values
By get
Get complete object
Update Set new values
Load
Select ....
If set the value it ill load each seeting a new proxy sl it ill degrade
performance...
In case of spring, the task of creating the objects, and supplying it where ever
necessary is taken over by Container.
how should i start explain about project architecture. means , what kind of thing i
have to tell.should i mention the technologies which i have used in my project .can
anyone tell me the best way to explain about project architecture?
Means explain this is the scenario where I used soap web service or rest
And always explain him like assume I have user online appointment page OK.
So tell their we have one registration page after fill data there is register
button, by clicking on that request goes to controller--service - - server
Validation - - - Dao
This is the sample I explained. Based on ur project flow, follow the same approach.
Can anyone post a example on how to create a simple maven multi module project
using spring MVC with service and dao with one working example ?
Yes I already did the same thing also I copied child module groupid, archetypeId
and version copied and attached in parent as a dependency , but where I need to
place our service and dao classes, when we run the parent project automatically all
child modules also get executed and display the output. How I will do it , can u
send me in sample and derive that process also.
Create a parrent folder and create pom for that. and then add code as per below.
And create separate folder for each module and they have their own pom again
<packaging>pom</packaging>
<modules>
<module>logging-module</module>
<module>scheduler-module</module>
<module>customer-module</module>
<module>sales-module</module>
</modules>
why we cannot apply j2ee security for web service security.why we should go for ws-
security?
We can add simple J2ee security also np. But it's is very less secure. Nd
internally ws policy or interceptor internally follow Web security only with
different mechanism like token, bit size increase
security will not work in all situations. There can come a time when the client can
talk to multiple servers. An example given below shows a client talking to both a
database and a web server at a time. In such cases, not all information can pass
through the https protocol This is where SOAP comes in action to overcome such
obstacles by having the WS-Security specification in place. With this
specification, all security related data is defined in the SOAP header element.
Hii everyone...
After completing the project architecture generally interviewed ask where u used
customer exception,multithreading,encapsulation,abstraction,and singleton bean...
in your peoject.... can any one explain all topic
Encapsulation :we used in our Entity/Model/pojo class
Custom Exception :Normally we are using it from dao and service layer like suppose
m searching user from db based on id.
If it is not found in db. Then from service we need to throw out custom exception
and in controller we need to use try catch to handle this.. Nd wrapping the failure
response in in catch itself.
If u r using Spring then u can say by default every bean scope is singleton so we
are not writing it manually.
Else tell like u r making singleton where u r getting SessionFactory instance and
Invoked class means which called other services.
We have custom exception for our project ,in that for a porject there is one base
exception,after that for module spearte exception is extended from base
exception,then for a layer exception and for operation one exception all those are
hierarchical
Hi,
in the scorecard, every second automatically refreshes and displays present score
how it works and implementing by using java?
I mean not using java only. Create an object scoreboard which gets updated on
every time a record being insert or update into db. In ui use meta refresh as 5 to
make your data update in every 5 seconds or else use ajax.
bro absolutely R8. For this we need to use any in memory container to update and
fetch.
package com.sjgm.question;
package com.sjgm.question;
@Override
scoreBoard.displayScore("IND", 50);
package com.sjgm.question;
this.scoreBoard = scoreBoard;
@Override
scoreBoard.displayScore("SA", 50);
package com.sjgm.question;
india.start();
southAfrica.start();
}
Asking in interviewer
1.wap to the prime number without using for loop.
2.calculate length of linked list without using counter.
Map is not a child interface of collection then what is the relation between them?
Collection was designed for better memory management in java based on Data
Structure..
If a Map is a Collection, what are the elements? The only reasonable answer is
"Key-value pairs", but this provides a very limited (and not particularly useful)
Map abstraction. You can't ask what value a given key maps to, nor can you delete
the entry for a given key without knowing what value it maps to.
Yes if we compare filter with interceptor then interceptor provide more features
like some predefined bean is there so we no need to write class and bunch of
configuration for it.
we have interface is there and again y enum was developed? interface contains final
variables and enum also final y?
Interface not Interduced to declare final variable..
1.what is difference between lazy loading and aggressive loading? 2.what is eager
and lazy fetch types? 3.what is the purpose of mapped by in hibernate?
Eager and Lazy fetch in hibernate
Just consider one to many examples like one customer by multiple products OK. So
what we have to do.
class Customer {
Private List<Product> products ;
}
class Product {}
So here when I want to load all parent with child then I need to specify fetch
eager.
If I will not specify it will take default value as lazy and will load only parents
not child.
@GET
@Produces("text/html")
public String doGetAsHtml() {
...
}
}
The @Consumes Annotation
The @Consumes annotation is used to specify which MIME media types of
representations a resource can accept, or consume, from the client. If @Consumes is
applied at the class level, all the response methods accept the specified MIME
types by default. If @Consumes is applied at the method level, it overrides any
@Consumes annotations applied at the class level.
If a resource is unable to consume the MIME type of a client request, the Jersey
runtime sends back an HTTP 415 Unsupported Media Type error.
The value of @Consumes is an array of String of acceptable MIME types. For example:
@Consumes({"text/plain,text/html"})
The following example shows how to apply @Consumes at both the class and method
levels:
@Path("/myResource")
@Consumes("multipart/related")
public class SomeResource {
@POST
public String doPost(MimeMultipart mimeMultipartData) {
...
}
@POST
@Consumes("application/x-www-form-urlencoded")
public String doPost2(FormURLEncodedProperties formData) {
...
}
}
AbstractDemo.m1();
}
}
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/*
* service.submit(task) will take my task and provide to my 2 thread
*/
Future<String> future = service.submit(new CallableSample());
System.out.println(future.get());
/*
* as its return type is void so we should prefer here Runnable insted
* of Callable if u want using ExecutorService Framework specially it
* will help full to achive thread pull concept
*/
service.execute(new Task());
}
}
@Override
public void run() {
System.out
.println("Hi It will execute by while call execute() cause no return type");
}
}
What is the difference between spring 2.0 and spring 3.0 and spring 4.0 ??????