gkguide.net-interview questions amp answers

Upload: gkguide

Post on 04-Apr-2018

241 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    1/19

    gkguide.net http://www.gkguide.net/p/interview-questions-answers.html

    Interview Questions & Answers

    Banking Interview Questions [Bank PO ,Clerk]

    1.Tell me something about yourself?

    2.Why you want to make a career in banking after doing MBA/Engg?

    3.What are your career goals (long term & short term)?

    4.What is Financial Inclusion?

    5.What is Repo rate/Reverse Repo Rate? What is the Difference between the two?

    SBI clerk Quest ions (all collected f rom ot her threads or f rom orkut)

    1-why r u interested in banking sector..??

    2-Do u support privatisation of banks? why..??

    3-Being in a public sector bank how can u compete with private sector banks...??

    4-what steps 2b taken 2 control global warming.?

    Questions posted by Akanshita

    1.wat is NPA?

    2.why do u want to join sbi.

    3.Tell something abt yourself?

    4.how many t ime u have cleared sbi exam?

    5.who is the current chairman of sbi?

    6.what is CRR?

    7.what is RR(Repo rate)?

    7.why did u choosed sbi for the job while pvt sector bank

    is paying heavy salary to his employee?

    8.which banned out f it is responsible for recent blast in

    dif ferent city of india?

    9.who is the governor of RBI?

    10.u have completed your graduation(if u have)in this year(-

    ----).what u were doing till now?

    11.who is the f inance secretary?

    # What is RR(Reporate)

    # Whats is CRR# Whats is reverse RR

    # Whats is SLR

    # Whats r d too ls with RBI to control liquidity in market

    http://www.gkguide.net/p/interview-questions-answers.html
  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    2/19

    # Who is d chairperson of RBI

    # Which bank recently got submerged in SBI

    # Who is the owner of SBI at present n with what % of shares

    # What was d name of f irst bank established in India ?

    # When was Stat e Bank of India established in India

    # Who is the Chairman of SBI

    # Financial crisis in America# Why joining SBI or Banking Sector

    # Questions on Hobby

    # Historical or geographical Importance of d place u live SBI clerk Qus (all collected from other

    threads or f rom orkut)

    1-why r u interested in banking sector..??

    2-Do u support privatisation of banks? why..??

    3-Being in a public sector bank how can u compete with private sector banks...??

    4-what steps 2b taken 2 control global warming.?

    1.wat is NPA?

    2.why do u want to join sbi.

    3.Tell something abt yourself?

    4.how many t ime u have cleared sbi exam?

    5.who is the current chairman of sbi?

    6.what is CRR?

    7.what is RR(Repo rate)?

    7.why did u choosed sbi for the job while pvt sector bank

    is paying heavy salary to his employee?

    8.which banned out f it is responsible for recent blast in

    dif ferent city of india?

    9.who is the governor of RBI?

    10.u have completed your graduation(if u have)in this year(-----).what u were doing till now?

    11.who is the f inance secretary?

    # What is RR(Reporate)

    # Whats is CRR

    # Whats is reverse RR

    # Whats is SLR

    # Whats r d too ls with RBI to control liquidity in market# Who is d chairperson of RBI

    # Which bank recently got submerged in SBI

    # Who is the owner of SBI at present n with what % of shares

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    3/19

    # What was d name of f irst bank established in India ?

    # When was Stat e Bank of India established in India

    # Who is the Chairman of SBI

    # Financial crisis in America

    # Why joining SBI or Banking Sector

    # Questions on Hobby

    # Historical or geographical Importance of d place u live

    SBI clerk Qus (all collected from ot her threads or f rom orkut)

    questions asked to me:

    since i am a comp. sci. student they asked what r d

    languages i hv learnt i replied c,c++ and now i learning

    vb... they asked the diff . bet . c and vb

    then hw computers r used in banks?earlier days v used maintain separate record for each n

    every person who hv account but after being computersied

    as v type the acc.no. it display all the details..

    then dd forms were computerised,earlier it was writ ten by

    hand ... then core banking...

    next i am a throwball player.... so they asked what 's d

    diff .bet throw ball and volley ball

    as i hv won state level certificate in elocution i was

    asked to speak abt . INDIA for 2 min.

    then t hey asked me wat i like n dislike in INDIA...

    since i'm 4m vandalur next t o chennai , it comes under

    kanchipuram dist. they quest ioned me "wat 's imp. regarding

    kanchipuram", i replied temples,dist .Head Quarter then

    kanchipuram silk...

    then they also asked me abtwat's imp. in vandalur

    next wat do u know abt SBI

    wat r the private banks ans. i replied ICICI and HDFC

    full form of ICICI ? Industrial Credit and Investment

    Corporation of India...

    Wat r the nat ionalised banks?

    since i am doing college ug f inal year they asked y do come

    for job when u r studying.....I replied that the main aim

    of studies is to know wat 's going around us and the next

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    4/19

    is to get the job .. when the oppurtunity knocks at me y

    shdn't i use it...

    then wat is u.s crisisSBI clerk Qus (all collected f rom other threads or f rom orkut)

    questions asked to me:

    since i am a comp. sci. student they asked what r d

    languages i hv learnt i replied c,c++ and now i learning

    vb... they asked the diff . bet . c and vb

    then hw computers r used in banks?

    earlier days v used maintain separate record for each n

    every person who hv account but after being computersied

    as v type the acc.no. it display all the details..

    then dd forms were computerised,earlier it was writ ten by

    hand ... then core banking...

    next i am a throwball player.... so they asked what 's d

    diff .bet throw ball and volley ball

    as i hv won state level certificate in elocution i was

    asked to speak abt . INDIA for 2 min.

    then t hey asked me wat i like n dislike in INDIA...

    since i'm 4m vandalur next t o chennai , it comes under

    kanchipuram dist. they quest ioned me "wat 's imp. regarding

    kanchipuram", i replied temples,dist .Head Quarter then

    kanchipuram silk...

    then they also asked me abtwat's imp. in vandalur

    next wat do u know abt SBI

    wat r the private banks ans. i replied ICICI and HDFC

    full form of ICICI ? Industrial Credit and Investment

    Corporation of India...

    Wat r the nat ionalised banks?

    since i am doing college ug f inal year they asked y do come

    for job when u r studying.....I replied that the main aim

    of studies is to know wat 's going around us and the next

    is to get the job .. when the oppurtunity knocks at me y

    shdn't i use it...then wat is u.s crisis

    ------------------------------------------------------------------------------------------------------------

    SBI clerk Qus (all collected from ot her threads or f rom orkut)

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    5/19

    we had 3 men n a lady to interview us.....one person asked me abt my hobbies [painting- colours

    n how do i select my theme to paint] and abt my plc and since i've writ ten Tally as my spcl

    course ..they asked me to tell abt t hat t oo ..

    2nd person asked me chairman of SBI n finance min of my state..

    3rd person asked me abt my native plc n abt deposits n loans provided by the bank..

    4th person asked me abt the speciality of a famous personality Sir M. Vishveshvaraiyya as he's

    the pioneer of the KRS Dam built in Mysore- a famous tourist at traction ...and abt debt waivers

    of farm loans.....

    Simple........and within 15 mins my interview was over !!!!!!!!!

    Keep Smiling throughout....if u dont know t ell it f rankly...no probs...they'll correct u if u r wrong.....

    ------------------------------------------------------------------------------------------------------------

    hi guy's today i given interview at hyd sbi learning centre.

    my interview was so cool. they just asked about my details

    and some computer questions i.e. what is dos?

    what is ram? and what is float ing and what is gravitat ional

    force,it is same for all materials or not

    and regarding about "gate way of india" where it is and y

    it has made?

    where is the india gate and y it has build?

    that sal......

    all the best for other guy's

    NIA interview questions

    What is CAR?

    Reinsurance?

    when is niacl established.?When is niacl nationalized.?

    What is CRR?

    Define SLR?

    how can we control the liquidity in system with CRR.?

    how much % Govt owns in Niacl.?

    How much %govt should own t o make the company govt owned?

    Tell me about recent un summit(copenhagen)?

    What is the prof it of NIACL?Income of NIACL?

    what is a liability ?

    what is insurance liability? (person got confused and confused me), Public liability?

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    6/19

    Why will you stay with niacl?

    suppose you got selected in Federal bank united bank of india and NIACL which one you

    choose and please be honest.?

    Interview: I was asked the following questions by the 4 member panel.I was the f irst to give

    interview that day. I am an MBA(Finance) from IBS,Mumbai.:

    1. What does ICFAI stands for ?

    2. Tell me something about ICFAI ?

    3. What is the CFA course of ICFAI ?

    4. My family background.

    5. What considerat ions should be taken while making a portf olio ?

    6. Where does an insurance company invests its funds ?

    7. What are treasury bills ?

    8. What is Yield ?

    9. How is yield related to market price ?

    10. What is HTM & AFS ?

    11. What is mark to market ?

    11. How is it important for insuarnce sector ?

    12. What are dated securities ?

    13. Founder of NIACL ?

    14. Paid up capital of NIACL ?

    15. What do you know about NIACL ?

    16. What are sources of income for NIACL?

    17. what are the disbursements for NIACL?

    18. How will you handle the situation if an experienced and old employee misbehaves with you

    in of f ice ?

    19. How much makrs i will give myself out of 10 for t his interview ?

    JAVA Interview Questions

    1. What is a virtual function in C++?

    Simply put, the virtual keyword enables a function to be virtual which then gives possibility forthat function to be overridden (redefined) in one or more descendant classes. It is a good

    feature since the specif ic funct ion to call is determined at run-time. In other words, a virtual

    function allows derived classes to replace the implementat ion provided by the base class.

    2. What is the diff erence between private, protected, and public?

    These keywords are for allowing privilages to components such as funct ions and variables.

    Public: accessible to all classes

    Private: accessible only to the class to which they belong

    Prot ected: accessible to the class to which they belong and any subclasses.

    3. What is a cartesian product in PL/SQL?

    When a Join condition is not specified by the programmer or is invalid(fails), PL/SQL forms a

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    7/19

    Cartesian product.

    In a Cartesian product, all combinations of rows will be displayed.

    For example, All rows in the f irst table are joined to all rows in the second t able. It joins a bunch

    of rows and its result is rarely useful unless you have a need to combine all rows from all

    tables.

    4. What is mutual exclusion? How can you take care of mutual exclusion using Java

    threads?

    Mutual exclusion is where no two processes can access critical regions of memory at the same

    time.

    Java provides many utilit ies to deal with mutual exclusion with the use of threaded

    programming.

    For mutual exclusion, you can simply use the synchronized keyword and explicitly or implicitly

    provide an Object, any Object, to synchronize on.

    The runtime system/Java compiler takes care of the gruesome details for you. The

    synchronized keyword can be applied to a class, to a method, or to a block of code. There are

    several methods in Java used for communicating mutually exclusive threads such as wait( ),

    not ify( ), or not ifyAll( ). For example, the not ifyAll( ) method wakes up all threads that are in the

    wait list of an object.

    5. What are some advantages and disadvantages of Java Sockets?

    Some advantages of Java Sockets:

    Sockets are f lexible and suff icient. Eff icient socket based programming can be easilyimplemented for general communications.

    Sockets cause low network traf f ic. Unlike HTML forms and CGI scripts that generate and

    transfer whole web pages for each new request, Java applets can send only necessary

    updated information.

    Some disadvantages of Java Sockets:

    Security restrictions are sometimes overbearing because a Java applet running in a Web

    browser is only able to establish connect ions to the machine where it came from, and to

    nowhere else on the network

    Despite all of the useful and helpful Java features, Socket based communicat ions allows only

    to send packets of raw data between applicat ions. Both the client-side and server-side have to

    provide mechanisms to make the data useful in any way.

    Since the data formats and protocols remain applicat ion specif ic, the re-use of socket based

    implementations is limited.

    1. What is the diff erence between an Interface and an Abstract class?

    An Abstract class declares have at least one instance method that is declared abstract which

    will be implemented by the subclasses. An abstract class can have instance methods that

    implement a def ault behavior. An Interface can only declare constants and instance methods,

    but cannot implement default behavior.

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    8/19

    2. What is the purpose of garbage collection in Java, and when is it used?

    The purpose of garbage collection is to identify and discard objects that are no longer needed

    by a program so t hat their resources can be reclaimed and reused. A Java object is subject to

    garbage collect ion when it becomes unreachable to the program in which it is used.

    3. Describe synchronizat ion in respect to mult ithreading.?

    With respect t o multithreading, synchronizat ion is the capability to cont rol the access of

    mult iple threads to shared resources. Without synchonizat ion, it is possible for one thread to

    modify a shared variable while another thread is in the process of using or updating same

    shared variable. This usually leads to signif icant errors.

    4. Explain different way of using thread?

    The thread could be implemented by using runnable interface or by inherit ing from the Thread

    class. The former is more advantageous, cause when you are going for multiple

    inheritance..the only interface can help.

    5. What are pass by reference and passby value?

    Pass By Reference means the passing the address itself rather than passing the value. Passby

    Value means passing a copy of the value to be passed.

    6. What is HashMap and Map?

    Map is Interface and Hashmap is class that implements that.

    7. Dif ference between HashMap and HashTable?

    The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and

    permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow).

    HashMap does not guarantee that the order of the map will remain constant over t ime.

    HashMap is non synchronized and Hashtable is synchronized.

    8. Dif ference between Vector and ArrayList?

    Vector is synchronized whereas arraylist is not .

    9. Dif ference between Swing and Awt?

    AWT are heavy-weight componenets. Swings are light-weight component s. Hence swing works

    faster than AWT.

    10. What is the difference between a constructor and a method?

    A const ructor is a member funct ion of a class that is used to create objects of that class. It has

    the same name as the class itself , has no return type, and is invoked using the new operator. A

    method is an ordinary member function of a class. It has its own name, a return type (which may

    be void), and is invoked using the dot operator.

    11. What is an Iterators?

    Some of the collection classes provide traversal of their contents via a java.util.Iterator

    interface. This interface allows you to walk a collection of objects, operating on each object in

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    9/19

    turn. Remember when using Iterators that t hey cont ain a snapshot of the collection at t he time

    the Iterator was obtained; generally it is not advisable to modify the collection itself while

    traversing an Iterator.

    12. State the significance of public, private, protected, default modifiers bot h singly and in

    combinat ion and state the eff ect o f package relat ionships on declared items qualif ied by these

    modifiers.?

    public : Public class is visible in other packages, field is visible everywhere (class must be public

    too) private : Private variables or methods may be used only by an instance of the same class

    that declares the variable or method, A private feature may only be accessed by the class that

    owns the feature. protected : Is available to all classes in the same package and also available

    to all subclasses of the class that owns the protected feat ure.This access is provided even to

    subclasses that reside in a dif ferent package from the class that owns the prot ected feature.

    default :What you get by default ie, without any access modifier (ie, public private or

    protected).It means that it is visible to all within a part icular package.

    13. What is an abstract class?

    Abst ract class must be extended/subclassed (to be useful). It serves as a template. A class that

    is abstract may not be instantiated (ie, you may not call its const ructor), abstract class may

    contain static data. Any class with an abstract method is automatically abstract itself, and must

    be declared as such. A class may be declared abstract even if it has no abstract methods. This

    prevents it from being instantiated.

    14. What is stat ic in java?Stat ic means one per class, not one for each object no matter how many instance of a class

    might exist. This means that you can use them without creat ing an instance of a class.Stat ic

    methods are implicitly final, because overriding is done based on t he type of the object, and

    stat ic methods are attached to a class, not an object. A stat ic method in a superclass can be

    shadowed by anot her stat ic method in a subclass, as long as the original method was not

    declared final. However, you cant override a stat ic method with a nonstatic method. In ot her

    words, you cant change a static method into an instance method in a subclass.

    1. What is f inal?

    A f inal class cant be extended ie., final class may not be subclassed. A f inal method cant be

    overridden when its class is inherited. You cant change value of a final variable (is a constant).

    2. Are the imports checked for validity at compile t ime? e.g. will the code containing an

    import such as java.lang.ABCD compile?

    Yes the imports are checked fo r the semantic validity at compile t ime. The code containing

    above line of import will not compile. It will throw an error saying,can not resolve symbol symbol

    : class ABCD location: package io import java.io.ABCD;

    3. Does importing a package imports the subpackages as well?

    e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    10/19

    No you will have to import the subpackages explicitly. Import ing com.MyTest .* will import

    classes in the package MyTest only. It will not import any class in any of its subpackage.

    4. What is the difference between declaring a variable and def ining a variable?

    In declaration we just mention t he type of the variable and its name. We do not initialize it. But

    def ining means declaration + initializat ion. e.g String s; is just a declaration while String s = new

    String (abcd); Or String s = abcd; are both definitions.

    5. What is the default value of an object reference declared as an instance variable?

    null unless we def ine it explicitly.

    6. Can a level class be private or prot ected?

    No. A level class can not be private or protected. It can have either public or no modifier. If it

    does not have a modifier it is supposed t o have a default access.If a level class is declared as

    private the compiler will complain that the modifier private is not allowed here. This means that

    a level class can not be private. Same is the case with protected.

    7. What type of parameter passing does Java support?

    In Java the arguments are always passed by value .

    8. Primitive data types are passed by reference or pass by value?

    Primitive data t ypes are passed by value.

    9. Objects are passed by value or by reference?

    Java only supports pass by value. With objects, the object reference itself is passed by valueand so both the original reference and parameter copy both refer to the same object .

    10. What is serializat ion?

    Serializat ion is a mechanism by which you can save the state of an object by convert ing it to a

    byte stream.

    11. How do I serialize an object to a f ile?

    The class whose instances are to be serialized should implement an interface Serializable. Then

    you pass the instance to the ObjectOutputStream which is connected to a f ileoutputst ream.This will save the object to a f ile.

    12. Which methods of Serializable interface should I implement?

    The serializable interface is an empty interface, it does not contain any methods. So we do not

    implement any methods.

    13. How can I customize the seralization process?

    i.e. how can one have a cont rol over the serializat ion process?

    Yes it is possible to have control over serialization process. The class should implement

    Externalizable interface. This interface contains two methods namely readExternal and

    writeExternal. You should implement these methods and write the logic for customizing the

    serialization process.

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    11/19

    14. What is an abstract class?

    Abst ract class must be extended/subclassed (to be useful). It serves as a template. A class that

    is abstract may not be instantiated (ie, you may not call its const ructor), abstract class may

    contain static data. Any class with an abstract method is automatically abstract itself, and must

    be declared as such. A class may be declared abstract even if it has no abstract methods. This

    prevents it from being instantiated.

    1. What is the common usage of serializat ion?

    Whenever an object is to be sent over the network, objects need to be serialized. Moreover if

    the state of an object is to be saved, objects need to be serilazed.

    2. What is Externalizable interface?

    Externalizable is an interface which contains two methods readExternal and writeExternal.

    These methods give you a control over the serializat ion mechanism. Thus if your class

    implements t his interface, you can customize the serializat ion process by implementing thesemethods.

    3. What happens to the object references included in the object?

    The serializat ion mechanism generates an object graph for serializat ion. Thus it determines

    whether the included object references are serializable or not. This is a recursive process. Thus

    when an object is serialized, all the included objects are also serialized alongwith the original

    obect.

    4. What one should take care of while serializing the object?

    One should make sure that all the included objects are also serializable. If any of the objects is

    not serializable then it t hrows a NotSerializableException.

    5. What if the main method is declared as private?

    The program compiles properly but at runtime it will give Main method not public. message.

    6. What if the static modifier is removed from the signature of the main method?

    Program compiles. But at runtime throws an error NoSuchMethodError.

    7. What if I write static public void instead of public static void?

    Program compiles and runs properly.

    8. What if I do not provide the String array as the argument to the method?

    Program compiles but throws a runtime error NoSuchMethodError.

    9. What is the f irst argument of the String array in main method?

    The String array is empty. It does not have any element . This is unlike C/C++ where the f irst

    element by default is the program name.

    10. If I do not provide any arguments on the command line, then the String array of Main

    method will be empty of null?

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    12/19

    It is empty. But not null.

    11. How can one prove that the array is not null but empty?

    Print args.length. It will print 0. That means it is empty. But if it would have been null then it

    would have thrown a NullPointerException on attempting to print args.length.

    12. What environment variables do I need to set on my machine in order to be able to run

    Java programs?

    CLASSPATH and PATH are the two variables.

    13. Can an applicat ion have mult iple classes having main method?

    Yes it is possible. While start ing the application we mention the class name to be run. The JVM

    will look for the Main method only in the class whose name you have mentioned. Hence there is

    not conf lict amongst the mult iple classes having main method.

    14. Can I have multiple main methods in the same class?

    No the program fails to compile. The compiler says that the main method is already defined in

    the class.

    15. Do I need to import java.lang package any t ime? Why ?

    No. It is by default loaded internally by the JVM.

    16. Can I import same package/class twice?

    Will the JVM load t he package twice at runtime?

    One can import the same package or same class mult iple t imes. Neither compiler nor JVMcomplains abt it . And the JVM will internally load the class only once no matt er how many times

    you import the same class.

    17. What are Checked and UnChecked Exception?

    A checked exception is some subclass of Exception (or Exception itself), excluding class

    RuntimeException and its subclasses. Making an exception checked forces client programmers

    to deal with the possibility that the exception will be thrown. eg, IOException thrown by

    ava.io.FileInputStreams read() method

    checked exceptions are RuntimeException and any of its subclasses. Class Error and its

    subclasses also are unchecked. With an unchecked exception, however, the compiler doesnt

    force client programmers either to catch the exception or declare it in a throws clause. In fact,

    client programmers may not even know that the except ion could be thrown. eg,

    StringIndexOutOfBoundsException thrown by Strings charAt() method Checked exceptions

    must be caught at compile t ime. Runt ime except ions do not need to be. Errors of ten cannot be.

    18. What is Overriding?When a class defines a method using the same name, return type, and arguments as a method

    in its superclass, the method in the class overrides the method in the superclass. When the

    method is invoked for an object o f the class, it is the new definit ion of the method that is

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    13/19

    called, and not the method definit ion f rom superclass. Methods may be overridden to be more

    public, not more private.

    19. What are dif ferent types of inner classes?

    They are Nested -level classes, Member classes, Local classes, Anonymous classes

    Nested -level classes- If you declare a class within a class and specify the static modifier, the

    compiler t reats the class just like any ot her -level class. Any class outside the declaring class

    accesses the nested class with the declaring class name act ing similarly to a package. eg,

    outer.inner. -level inner classes implicit ly have access only to stat ic variables.There can also be

    inner interfaces. All of these are of the nested -level variety.

    Member classes Member inner classes are just like other member methods and member

    variables and access to the member class is restricted, just like methods and variables. This

    means a public member class acts similarly to a nested -level class. The primary difference

    between member classes and nested -level classes is that member classes have access to thespecif ic instance of the enclosing class.

    Local classes Local classes are like local variables, specific to a block o f code. Their visibility is

    only within the block of their declaration. In order for the class to be useful beyond the

    declaration block, it would need to implement a more publicly available interface.Because local

    classes are not members, the modifiers public, protected, private, and stat ic are not usable.

    Anonymous classes Anonymous inner classes extend local inner classes one level further. As

    anonymous classes have no name, you cannot provide a const ructor.

    1. Are the imports checked for validity at compile t ime? e.g. will the code containing an

    import such as java.lang.ABCD compile? Yes the imports are checked for the semantic validity

    at compile t ime. The code containing above line of import will not compile. It will throw an error

    saying,can not resolve symbol symbol : class ABCD locat ion: package io import java.io.ABCD;

    2. Does importing a package imports the subpackages as well? e.g. Does importing

    com.MyTest.* also import com.MyTest.UnitTests.*? No you will have to import the

    subpackages explicitly. Import ing com.MyTest .* will import classes in the package MyTest only.

    It will not import any class in any of its subpackage.

    3. What is the difference between declaring a variable and def ining a variable? In declaration

    we just mention t he type of the variable and its name. We do not init ialize it . But defining

    means declaration + initializat ion. e.g String s; is just a declaration while String s = new String

    (abcd); Or String s = abcd; are both definitions.

    4. What is the default value of an object reference declared as an instance variable? nullunless we define it explicitly.

    5. Can a level class be private or prot ected? No. A level class can not be private or

    protected. It can have either public or no modifier. If it does not have a modifier it is supposed

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    14/19

    to have a default access. If a level class is declared as private the compiler will complain that the

    modif ier private is not allowed here. This means that a level class can not be private. Same is

    the case with prot ected.

    6. What type of parameter passing does Java support? In Java the arguments are always

    passed by value .

    7. Primitive data types are passed by reference or pass by value? Primitive data types are

    passed by value.

    8. Objects are passed by value or by reference? Java only supports pass by value. With

    objects, the object reference itself is passed by value and so both the original reference and

    parameter copy both refer to the same object .

    9. What is serializat ion? Serializat ion is a mechanism by which you can save the state of an

    object by converting it to a byte stream.

    10. How do I serialize an object to a f ile? The class whose instances are to be serialized

    should implement an interface Serializable. Then you pass the instance to the

    ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a

    file.

    11. Which methods of Serializable interface should I implement? The serializable interface is

    an empty interface, it does not contain any methods. So we do not implement any methods.

    12. How can I customize the seralization process? i.e. how can one have a control over the

    serializat ion process? Yes it is possible to have cont rol over serializat ion process. The class

    should implement Externalizable interface. This interface contains two methods namely

    readExternal and writeExternal. You should implement these methods and write the logic for

    customizing the serializat ion process.

    13. What is the common usage of serializat ion? Whenever an object is to be sent over the

    network, objects need to be serialized. Moreover if the state of an object is to be saved,

    objects need to be serilazed.

    14. What is Externalizable interface? Externalizable is an interface which cont ains two

    methods readExternal and writeExternal. These methods give you a cont rol over the

    serializat ion mechanism. Thus if your class implements t his interface, you can customize the

    serializat ion process by implementing these methods.

    15. What happens to the object references included in the object? The serializat ion

    mechanism generates an object graph for serializat ion. Thus it det ermines whether the included

    object references are serializable or not. This is a recursive process. Thus when an object is

    serialized, all the included objects are also serialized alongwith the original obect.

    16. What one should take care of while serializing the object? One should make sure that all

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    15/19

    the included objects are also serializable. If any of the objects is not serializable then it t hrows a

    NotSerializableException.

    17. What happens to t he stat ic f ields of a class during serializat ion? Are these f ields serialized

    as a part o f each serialized object? Yes the static fields do get serialized. If the static field is an

    object then it must have implemented Serializable interface. The stat ic fields are serialized as a

    part of every object. But the commonness of the stat ic f ields across all the instances is

    maintained even after serializat ion.

    18. How are Observer and Observable used? Objects that subclass the Observable class

    maintain a list of observers. When an Observable object is updated it invokes the update()

    method of each of its observers to not ify the observers that it has changed state. The

    Observer interface is implemented by objects that observe Observable objects. [Received f rom

    Venkateswara Manam]

    19. What is synchronizat ion and why is it important? With respect to mult ithreading,synchronizat ion is the capability to control the access of mult iple threads to shared resources.

    Without synchronizat ion, it is possible fo r one thread to modify a shared object while anot her

    thread is in the process of using or updating that objects value. This of ten leads to signif icant

    errors.

    20. How does Java handle integer overf lows and underflows? It uses those low order bytes

    of the result that can fit into the size of the type allowed by the operat ion.

    21. Does garbage collection guarantee that a program will not run out of memory? Garbage

    collection does not guarantee that a program will not run out of memory. It is possible fo r

    programs to use up memory resources faster than they are garbage collected. It is also possible

    for programs to create objects that are not subject t o garbage collection .

    22. What is the difference between preemptive scheduling and t ime slicing? Under preemptive

    scheduling, the highest priority task executes until it enters the waiting or dead states or a

    higher priority task comes into existence. Under t ime slicing, a task executes f or a predefined

    slice of t ime and then reenters the pool of ready tasks. The scheduler then determines whichtask should execute next, based on priority and ot her factors.

    23. When a thread is created and started, what is its initial state? A thread is in the ready

    state aft er it has been created and started.

    24. What is the purpose of f inalizat ion? The purpose of f inalizat ion is to give an unreachable

    object t he opportunity to perform any cleanup processing before the object is garbage

    collected.

    25. What is the Locale class? The Locale class is used to tailor program out put to the

    convent ions of a particular geographic, political, or cultural region.

    26. What is the difference between a while statement and a do stat ement? A while statement

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    16/19

    checks at the beginning of a loop to see whether the next loop iteration should occur. A do

    statement checks at the end of a loop to see whether the next iterat ion of a loop should

    occur. The do statement will always execute the body of a loop at least once.

    27. What is the difference between static and non-static variables? A stat ic variable is

    associated with the class as a whole rather than with specif ic instances of a class. Non-stat ic

    variables take on unique values with each object instance.

    28. How are this() and super() used with const ructors? this() is used to invoke a constructor

    of the same class. super() is used to invoke a superclass const ructor.

    1. Explain the life cycle methods of a Servlet.

    The javax.servlet.Servlet interface defines the three methods known as life-cycle method.

    public void init(ServletConfig config) throws ServletException public void service(

    ServletRequest req, ServletResponse res) throws ServletException, IOException public void

    destroy() First t he servlet is const ructed, then initialized wih the init () method. Any request f romclient are handled init ially by the service() method before delegating to the doXxx() methods in

    the case of HttpServlet . The servlet is removed f rom service, destroyed with the destroy()

    methid, then garbaged collected and f inalized.

    2. What is the diff erence between the getRequestDispatcher(String path) method of

    avax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?

    The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface

    accepts parameter the path to the resource to be included or fo rwarded to , which can be

    relative to t he request of the calling servlet. If the path begins with a / it is interpreted as

    relat ive to t he current context root .

    The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface

    cannot accepts relat ive paths. All path must sart with a / and are interpreted as relative to

    curent context root .

    3. Explain the directory structure of a web application.

    The directory structure of a web applicat ion consists of two parts. A private directory called

    WEB-INF A public resource directory which contains public resource folder. WEB-INF folder

    consists of 1. web.xml

    2. classes directory

    3. lib directory

    4. What are the common mechanisms used for session tracking?

    Cookies SSL sessions URL- rewriting

    5. Explain ServletContext.

    ServletContext interface is a window f or a servlet to view its environment. A servlet can use

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    17/19

    this interface to get information such as initialization parameters for the web applicationor

    servlet cont ainers version. Every web application has one and only one ServletContext and is

    accessible to all active resource of that applicat ion.

    6. What is preinit ialization of a servlet?

    A cont ainer doesnot init ialize the servlets ass soon as it starts up, it initializes a servlet when it

    receives a request for t hat servlet f irst t ime. This is called lazy loading. The servlet specif ication

    defines the element, which can be specified in the deployment descriptor to make the servlet

    container load and initialize the servlet as soon as it starts up. The process of loading a servlet

    before any request comes in is called preloading or preinit ializing a servlet .

    7. What is the diff erence between Dif ference between doGet() and doPost ()?

    A doGet() method is limited with 2k of data to be sent , and doPost() method doesnt have this

    limitation. A request string for doGet() looks like the following: ht tp://www.allapplabs.com/svt1?

    p1=v1&p2=v2&&pN=vN

    doPost () method call doesnt need a long t ext tail after a servlet name in a request. All

    parameters are stored in a request itself, not in a request st ring, and it s impossible to guess

    the data t ransmitted to a servlet only looking at a request st ring.

    8. What is the diff erence between HttpServlet and GenericServlet?

    A GenericServlet has a service() method aimed to handle requests.

    HttpServlet extends GenericServlet and adds support for doGet(), doPost(), doHead() methods

    (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods (HTTP 1.1). Both these

    classes are abstract.

    1. What is a output comment?

    A comment that is sent to the client in the viewable page source.The JSP engine handles an

    output comment as uninterpreted HTML text, returning the comment in the HTML output sent

    to t he client. You can see the comment by viewing the page source from your Web browser.

    JSP Syntax Example 1 Displays in the page source:

    2. What is a Hidden Comment?

    A comments that documents the JSP page but is not sent to t he client. The JSP engine

    ignores a hidden comment, and does not process any code within hidden comment tags. A

    hidden comment is not sent to the client, either in the displayed JSP page or the HTML page

    source. The hidden comment is useful when you want t o hide or comment out part of your

    JSP page. You can use any characters in the body of the comment except the closing %>

    combinat ion. If you need to use %> in your comment, you can escape it by typing %\>. JSPSyntax Examples

    3. What is a _Expression?

    An _expression tag cont ains a script ing language _expression that is evaluated, converted to a

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    18/19

    String, and inserted where the _expression appears in the JSP file. Because the value of an

    _expression is converted to a String, you can use an _expression within text in a JSP f ile. Like

    You cannot use a semicolon to end an _expression

    4. What is a Declaration?

    A declarat ion declares one or more variables or methods for use later in the JSP source file. A

    declaration must contain at least one complete declarative stat ement. You can declare any

    number of variables or methods within one declaration t ag, as long as they are separated by

    semicolons. The declaration must be valid in the scripting language used in the JSP f ile.

    5. What is a Scriptlet?

    A script let can contain any number of language statements, variable or method declarat ions, or

    expressions that are valid in the page scripting language.Within scriptlet tags, you can

    1.Declare variables or methods to use later in the file (see also Declaration).

    2.Write expressions valid in the page scripting language (see also _Expression).

    3.Use any of the JSP implicit objects or any object declared with a tag.

    You must write plain text, HTML-encoded text, or other JSP tags outside the script let .

    Scriptlets are executed at request t ime, when the JSP engine processes the client request. If

    the scriptlet produces output, the output is stored in the out object, from which you can display

    it.

    6. What are implicit objects? List them?

    Certain objects that are available for the use in JSP documents without being declared first .

    These objects are parsed by the JSP engine and inserted into the generated servlet. The

    implicit objects re listed below request response pageContext session application out conf ig

    page exception

    7. Dif ference between forward and sendRedirect?

    When you invoke a forward request, the request is sent to another resource on the server,

    without t he client being informed that a dif ferent resource is going to process the request. This

    process occurs completly with in the web container. When a sendRedirtect method is invoked,

    it causes the web cont ainer to return to t he browser indicat ing that a new URL should be

    requested. Because the browser issues a completly new request any object that are stored as

    request at tributes before the redirect occurs will be lost . This extra round t rip a redirect is

    slower than forward.

    8. What are the diff erent scope valiues for the ?

    The diff erent scope values fo r are1. page

    2. request

    3.session

  • 7/30/2019 Gkguide.net-Interview Questions Amp Answers

    19/19

    4.application

    9. Explain the life-cycle mehtods in JSP?

    THe generated servlet class fo r a JSP page implements the HttpJspPage interface of the

    avax.servlet.jsp package. Hte HttpJspPage interface extends the JspPage interface which

    inturn extends the Servlet interface of the javax.servlet package. the generated servlet class

    thus implements all the methods of the these three interfaces.

    The JspPage interface declares only two mehtods jspInit() and jspDestroy() that must be

    implemented by all JSP pages regardless of the client-server protocol.

    However the JSP specif icat ion has provided the HttpJspPage interfaec specif ically for the JSp

    pages serving HTTP requests.

    This interface declares one method _jspService(). The jspInit()- The container calls the jspInit()

    to init ialize te servlet instance.It is called before any other method, and is called only once f or a

    servlet instance.The _jspservice()- The container calls the _jspservice() for each request, passing it the request

    and the response objects.

    The jspDestroy()- The container calls this when it decides take the instance out of service. It is

    the last method called n the servlet instance.