Total Pageviews

Tuesday, 19 August 2014

Questions on Java

Friends , here is my first attempt , the SCJP book by Kathy has given me few questions ,  I would like to enrich it further , but time for a first cut

OOPS, Java

·         Is Java compiled or interpreted?
·         How can we declare two public classes in a Java source file?
·         Is there a restriction on naming the source file?
·         Give an example of code statement, where do while and while will give different output?
·         What is the default access, if we do not specify any access modifiers?
·         How method overloading and method overriding is different?
·         Give example of a non access modifier?
·         Why should some classes or methods be marked as final? 
·         How the abstract class is different from an interface as far as abstract methods are concerned?
·         How garbage collection works in C# and Java ?
·         What is boxing and Unboxing ?
·         How can we implement threads ?
·         What are the different states of a thread ?
·         What is a web service?  How this is related with SOAP, UDDI and WSDL?
·         What are the different ways to maintain state in a web application , relative advantage and disadvantages ? ( Hint : Session Variable, Cookies , Hidden Fields , Query String ) . For .Net view state is important.
·         What is MVC Architecture ?
·         Explain 3- tier Architecture ?
·         Explain Service oriented architecture
·         What is the difference between default and package access modifier
·         Let’s say Class A has a private method called fun() , class B extends Class A and defined fun() , what this phenomenon is called ?
·         What is the use of Final Keyword ?  Can we declare a variable as final ?
·         Is it possible to define a abstract class , with non abstract member s?
·         When should we use an arraylist in place of an array?
·         What is the method that can be used to traverse an arraylist?
·         What is checked and unchecked exception ?  Give example of both type of exceptions.
·         How to use your own exception , so let’s say you are taking age as an input and you want to throw an exception when it is less than zero, how will you achieve it ?
·         Give some example of statements that should be put in finally ?
·         Does Java allow multiple inheritance  ?  What is ‘Deadly Diamond of Death”
·         Class A
{
    public void fun()
 { 

}
}

Class B extend A
{
   Protected void fun()
}

Is there a problem in the above code ?

·         Give an example how polymorphism can be achieved using method overriding?
public int foo()
{
char c = ‘c’;
return c
}
Is this code legal ?
·         What is default constructor supplied by the compiler ? Is there any caution , that you need to follow when you create your own constructor,  will the default constructor be supplied in the following case

class Horse()
{
    void Horse ()
}

·         Which variables are in stack , which are stored in heap ?
·         What do we mean by saying strings are immutable objects ?   what is role of ‘String Constant Pool” . Which classed do we use to overcome the limitations of string ?