Question 8: What is difference between Encapsulation and Abstraction?

  1. Abstraction solves the problem at design level while encapsulation solves the problem at implementation level
  2. Abstraction is used for hiding the unwanted data and giving relevant data. While Encapsulation means hiding the code and data into a single unit to protect the data from outside world.
  3. Abstraction lets you focus on what the object does instead of how it does it while Encapsulation means hiding the internal details or mechanics of how an object does something.

4.  For example: Outer Look of a Television, like it has a display screen and channel buttons to change channel it explains Abstraction but Inner Implementation detail of a Television how CRT and Display Screen are connect with each other using different circuits , it explains Encapsulation.

 

Question 9: Different kinds of variable in java:

 

Class variable :

field declared using the keyword static within a class declaration , or with or without the keyword static within an interface declaration . A class variable is created when its class or interface is prepared and is initialized to a default value. The class variables effectively exist when its class or interface is unloaded.

Instance variable:

field declared within a class declaration without using the keyword static . If a class Abc has a field T as an instance variable, then a new instance variable T is created and initialized to a default value as part of each newly created object of class Abc or for any class that is a subclass of Abc. The instance variable effectively exist when the object of which it is a field is no longer referenced.

Array components :

Un-named variables that are created and initialized to default values whenever a new object of an array is created . The array components exist when the array is no longer referenced.

Method parameters :

Name argument values passed to a method. For every parameter declared in a method declaration, a new parameter variable is created each time that method is invoked. The new variable is initialized with the corresponding argument value from the method invocation. The method parameter exist when the execution of the body of the method is complete.

Constructor parameters :

Name argument values passed to a constructor. For every parameter declared in a constructor declaration, a new parameter variable is created each time a class instance creation or explicit constructor invocation invokes that constructor. The new variable is initialized with the corresponding argument value from the creation expression or constructor invocation. The constructor parameter exists when the execution of the body of the constructor is complete.

 

 

An exception-handler parameter:

Created each time an exception is caught by a catch clause of a try statement. The new variable is initialized with the actual object associated with the exception. The exception-handler parameter exists when execution of the block associated with the catch clause is complete.

 

Local variables:

Declared by local variable declaration statements. Whenever the flow of control enters a block or for loop statement or any other loop, a new variable is created for each local variable declared in a local variable declaration statement .A local variable declaration statement may contain an expression which initializes the variable. The local variable with an initializing expression is not initialized, until the local variable declaration statement that declares it is executed. The local variable effectively when the execution of the block or for statement is complete.

 

Note: variables in case of method parameter, constructor parameter and exceptional handler parameter is also termed as “local variable”

 

 

Question 10: Is tomcat an application server?

 

I can’t say it’s concluded answer but i will put few points

Tomcat has been referred to as an implementation of the Servlet/JSP APIs (i.e., a Servlet container).

It also provides an implementation of the JNDI and JMX

APIs. However, Tomcat is not a complete Java EE application server; it doesn’t provide support for even a majority of the Java EE APIs.

Many application servers actually use Tomcat as their implementation of the Servlet and JSP APIs.

The JBoss application servers explicit use Tomcat.

Developers seeking to create Java Web applications that utilize the Servlet, JSP, JNDI, and JMX APIs find Tomcat an excellent solution.

 

Question 11: What is Http? Why it is required ?

HTTP means Hypertext Transfer Protocol. HTTP is the protocol that lets us search for a book on Google and buy one from flipkart.com. It’s also the protocol that lets us reunite with old friends on a facebook chat or watch a music video on you tube. It’s a protocol that allows a web server from a data center in the United States to ship information to an Internet cafe in India where a student can read a web page describing the Great Wall of China. I.

Having a solid understanding of HTTP can help you write better web applications and web services. It can also help you debug applications and services when things go wrong.

 

Question 12. What is URL?

Uniform Resource Locator. It represents HTTP address.

 

This is example: http://www.facebook.com/pages/Java_Learners/542357679213597

 

1st there is http part before colon and double slash it is called as URL scheme or protocol and describes how to access particular resource.

The first part after colon slash is facebook.com that is called as host. This part tells browser which computer on internet is hosting the resource.

The last path of URL is URL path which tells which specific resources is requested by this path. Including URL scheme, host name, URL path, URLs also contain port number that host is going to use to listen for Http request. The default port for Http is port 80. Port no is not visible in url.

 

Consider another URL as: http://google.com/search?q=java.

What is significance of ?q=java?

It represent query or query string.

 

Consider URL as:http://wikipedia.org/wiki/java#description

What #description represents? What is its significance?

It represents fragments and using this it makes that part appear on top of screen.

 

Question 13: What is URL encoding?

it helps to understand the safe and unsafe character that can be used with URLs. and how unsafe characters can be encoded in URLs. Example: http://abc.com/aman%20shekhar.

How different contents like image, videos or other different documents are handled between client and host. The content type a server depends on multi-purpose internet main extension or MIME standards.