www.javaquestionbank.net 1 Java Question & Answer by KK Matam - share ur Knowledge and multiply it.
www.javaquestionbank.net 2 Q)Is it possible to provide a class inside an Interface? ========================================== Yes,it is possible to declare a class inside an interface.If we declare a class inside an interface then that class is becoming as static inner class,where we can access the members like static inner class members. example interface I{ class A { void m1(){ System.out.println("m1-A");} void m2(){ System.out.println("m2-A");}} } class Test { public static void main(String args[]){ I.A ia=new I.A(); ia.m1(); ia.m2(); } }
www.javaquestionbank.net 3 What is Method local Inner Class? =========================== Ans: •Declaring a class Inside a method is called as Method Local Inner class. • If we declare a class inside a method then that class is having scope upto the respective method. •In the case of method local Inner classes,we have to create object for the Inner class and we have to access members of the inner class inside the respective method only.
www.javaquestionbank.net 4 Q: What are the differences between Web Servers and Application Servers? Ans: 1. Web Server is a server, which will provide very good environment to execute web applications only. But Application servers will provide very good environment to execute any type of J2EE applications like web applications, distributed applications and so on. 2. In general web servers will not provide all the middle ware services. But application servers will provide all the middle ware services like JND, Jdbc and so on as in-built support. Application server = Web server + Middleware services Note: Initially the main intention of web servers is to execute static resources in order to generate static response and the main intention of application servers is to execute dynamic resources in order to generate dynamic response.
www.javaquestionbank.net 5 Q: What is the difference between POST request and PUT request? Ans: Both POST request and PUT request can be used to upload the data on the server machine. To upload the data on server machine if we use POST request then it is not mandatory to specify particular address location along with POST request. To upload the data on server machine if we use PUT request then it is mandatory to specify server side location along with PUT request.
www.javaquestionbank.net 6 Q: What is the difference between GET request and HEAD request? Ans: If we send Get request for a particular resource available at server machine then server will send only the requested resource as a response to client. If we send HEAD request for a particular resource available at server then server will send requested resource as well as the metadata about the requested resource as response. Note: Internally HEAD request uses GET request to get the requested resource from server.
www.javaquestionbank.net 7 For more visit us on: www.javaquestionbank.net Fbpage : www.facebook.com/JavaEncyclopedia

Java Question & Answers - I

  • 1.
    www.javaquestionbank.net 1 Java Question& Answer by KK Matam - share ur Knowledge and multiply it.
  • 2.
    www.javaquestionbank.net 2 Q)Is itpossible to provide a class inside an Interface? ========================================== Yes,it is possible to declare a class inside an interface.If we declare a class inside an interface then that class is becoming as static inner class,where we can access the members like static inner class members. example interface I{ class A { void m1(){ System.out.println("m1-A");} void m2(){ System.out.println("m2-A");}} } class Test { public static void main(String args[]){ I.A ia=new I.A(); ia.m1(); ia.m2(); } }
  • 3.
    www.javaquestionbank.net 3 What isMethod local Inner Class? =========================== Ans: •Declaring a class Inside a method is called as Method Local Inner class. • If we declare a class inside a method then that class is having scope upto the respective method. •In the case of method local Inner classes,we have to create object for the Inner class and we have to access members of the inner class inside the respective method only.
  • 4.
    www.javaquestionbank.net 4 Q: Whatare the differences between Web Servers and Application Servers? Ans: 1. Web Server is a server, which will provide very good environment to execute web applications only. But Application servers will provide very good environment to execute any type of J2EE applications like web applications, distributed applications and so on. 2. In general web servers will not provide all the middle ware services. But application servers will provide all the middle ware services like JND, Jdbc and so on as in-built support. Application server = Web server + Middleware services Note: Initially the main intention of web servers is to execute static resources in order to generate static response and the main intention of application servers is to execute dynamic resources in order to generate dynamic response.
  • 5.
    www.javaquestionbank.net 5 Q: Whatis the difference between POST request and PUT request? Ans: Both POST request and PUT request can be used to upload the data on the server machine. To upload the data on server machine if we use POST request then it is not mandatory to specify particular address location along with POST request. To upload the data on server machine if we use PUT request then it is mandatory to specify server side location along with PUT request.
  • 6.
    www.javaquestionbank.net 6 Q: Whatis the difference between GET request and HEAD request? Ans: If we send Get request for a particular resource available at server machine then server will send only the requested resource as a response to client. If we send HEAD request for a particular resource available at server then server will send requested resource as well as the metadata about the requested resource as response. Note: Internally HEAD request uses GET request to get the requested resource from server.
  • 7.
    www.javaquestionbank.net 7 For morevisit us on: www.javaquestionbank.net Fbpage : www.facebook.com/JavaEncyclopedia