0% found this document useful (0 votes)
61 views26 pages

Gurgaon: World College of Technology & Management

The document provides an example of a practice question set prepared by Shalini Johari for a 5th semester Web Development class at World College of Technology & Management. It includes 5 questions on topics related to object-oriented programming in Java, such as OOP features of Java, classes, method overloading, constructors, inheritance, interfaces, packages, exceptions handling, and multithreading. Detailed solutions explaining each concept are provided for each question.

Uploaded by

Rajat Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views26 pages

Gurgaon: World College of Technology & Management

The document provides an example of a practice question set prepared by Shalini Johari for a 5th semester Web Development class at World College of Technology & Management. It includes 5 questions on topics related to object-oriented programming in Java, such as OOP features of Java, classes, method overloading, constructors, inheritance, interfaces, packages, exceptions handling, and multithreading. Detailed solutions explaining each concept are provided for each question.

Uploaded by

Rajat Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

WORLD COLLEGE OF TECHNOLOGY & MANAGEMENT

Subject:

Web Development

Class:

CSC 5th Semester

Practice questioners prepared by Shalini Johari

Q.1.

Explain OOP features of java?

Solution:

AO

Object Oriented Programming or OOP is the technique to create programs based on the real
world. Unlike procedural programming, here in the OOP programming model programs are
organized around objects and data rather than actions and logic. Objects represent some
concepts or things and like any other objects in the real Objects in programming language have
certain behavior, properties, type, and identity. In OOP based language the principal aim is to
find out the objects to manipulate and their relation between each other. OOP offers greater
flexibility and compatibility and is popular in developing larger application. Another important
work in OOP is to classify objects into different types according to their properties and behavior.
So OOP based software application development includes the analysis of the problem,
preparing a solution, coding and finally its maintenance.

TM

Java is a object oriented programming and to understand the functionality of OOP in Java, we
first need to understand several fundamentals related to objects. These include class, method,
inheritance, encapsulation, abstraction, polymorphism etc.

W
C

Class - It is the central point of OOP and that contains data and codes with behavior. In Java
everything happens within class and it describes a set of objects with common behavior. The
class definition describes all the properties, behavior, and identity of objects present within that
class. As far as types of classes are concerned, there are predefined classes in languages like
C++ and Pascal. But in Java one can define his/her own types with data and code.
Object - Objects are the basic unit of object orientation with behavior, identity. As we mentioned
above, these are part of a class but are not the same. An object is expressed by the variable
and methods within the objects. Again these variables and methods are distinguished from each
other as instant variables, instant methods and class variable and class methods.
Methods - We know that a class can define both attributes and behaviors. Again attributes are
defined by variables and behaviors are represented by methods. In other words, methods define
the abilities of an object.

Inheritance - This is the mechanism of organizing and structuring software program. Though
objects are distinguished from each other by some additional features but there are objects that
share certain things common. In object oriented programming classes can inherit some
common behavior and state from others. Inheritance in OOP allows to define a general class
and later to organize some other classes simply adding some details with the old class
definition. This saves work as the special class inherits all the properties of the old general class
and as a programmer you only require the new features. This helps in a better data analysis,
accurate coding and reduces development time.
Abstraction - The process of abstraction in Java is used to hide certain details and only show
the essential features of the object. In other words, it deals with the outside view of an object
(interface).

AO

Encapsulation - This is an important programming concept that assists in separating an object's


state from its behavior. This helps in hiding an object's data describing its state from any further
modification by external component. In Java there are four different terms used for hiding data
constructs and these are public, private, protected and package. As we know an object can
associated with data with predefined classes and in any application an object can know about
the data it needs to know about. So any unnecessary data are not required by an object can be
hidden by this process. It can also be termed as information hiding that prohibits outsiders in
seeing the inside of an object in which abstraction is implemented.

Q.2.

W
C

TM

Polymorphism - It describes the ability of the object in belonging to different types with specific
behavior of each type. So by using this, one object can be treated like another and in this way it
can create and define multiple level of interface. Here the programmers need not have to know
the exact type of object in advance and this is being implemented at runtime.

What do you mean by class in java? Describe the following:


a) Method overloading
b) Constructor

Solution:

Method overloading:
In Java it is possible to define two or more methods within the same class that share the
same name, as long as their parameter declarations are different. When this is the case,
the methods are said to be overloaded, and the process is referred to as method
overloading. Method overloading is one of the ways that Java implements
polymorphism.
Demonstrate method overloading.
class OverloadDemo {

AO

void test() {
System.out.println("No parameters");
}
// Overload test for one integer parameter.
void test(int a) {
System.out.println("a: " + a);
}
// Overload test for two integer parameters.
void test(int a, int b) {
System.out.println("a and b: " + a + " " + b);
}
// overload test for a double parameter
double test(double a) {
System.out.println("double a: " + a);
return a*a;
}
}

W
C

TM

class Overload {
public static void main(String args[]) {
OverloadDemo ob = new OverloadDemo();
double result;
// call all versions of test()
ob.test();
ob.test(10);
ob.test(10, 20);
result = ob.test(123.2);
System.out.println("Result of ob.test(123.2): " + result);
}
}
Constructors:
A constructor is a special method that is used to initialize a newly created object and is called
just after the memory is allocated for the object
It can be used to initialize the objects ,to required ,or default valuesat the time of object creation
It is not mandatory for the coder to write a constructor for the class.
In order to create a Constructor observe the following rules
1) It has the same name as the class
2) It should not return a value not even void
class Demo{
int value1;

int value2;
Demo(){
value1 = 10;
value2 = 20;
System.out.println("Inside Constructor");
}

AO

public void display(){


System.out.println("Value1 === "+value1);

System.out.println("Value2 === "+value2);

}
}
Q.3.

W
C

d1.display();

TM

Demo d1 = new Demo();

public static void main(String args[]){

Define multilevel inheritance with example.

Solution:
The inheritance allows subclasses to inherit allproperties (variables and methods) of their parent
classes. The different forms of inheritance are:
Single inheritance (only one super class)
Multiple inheritance (several super classes)
Hierarchical inheritance (one super class, many sub classes)
Multi-Level inheritance (derived from a derived class)

Hybrid inheritance (more than two types)


Multilevel Inheritance
It is the enhancement of the concept of inheritance. When a subclass is derived from a derived
class then this mechanism is known as the multilevel inheritance. The derived class is called the
subclass or child class for it's parent class and this parent class works as the child class for it's
just above ( parent ) class. Multilevel inheritance can go up to any number of level.
e.g.
class A {
int x;

AO

int y;
int get(int p, int q){

x=p; y=q; return(0);

void Show(){

System.out.println(x);

}
class B extends A{

W
C

void Showb(){

TM

System.out.println("B");
}
}

class C extends B{
void display(){
System.out.println("C");
}
public static void main(String args[]){

A a = new A();
a.get(5,6);
a.Show();
}
}
Q.4.

What is java interface? Can we achieve multiple inheritance with the help of interface?
Explain with suitable example.

Solution:

AO

In the Java programming language, an interface is a reference type, similar to a class, that can
contain only constants, method signatures, and nested types. There are no method bodies.
Interfaces cannot be instantiatedthey can only beimplemented by classes or extended by
other interfaces.

Multiple Inheritance

The mechanism of inheriting the features of more than one base class into a single class is
known as multiple inheritance. Java does not support multiple inheritance but the multiple
inheritance can be achieved by using the interface.

TM

/* Area Of Rectangle and Triangle using Interface * /

W
C

interface Area
{
float compute(float x, float y);
}

class Rectangle implements Area


{
public float compute(float x, float y)
{
return(x * y);
}
}
class Triangle implements Area
{
public float compute(float x,float y)
{
return(x * y/2);

}
}
class InterfaceArea
{
public static void main(String args[])
{
Rectangle rect = new Rectangle();
Triangle tri = new Triangle();
Area area;
area = rect;
System.out.println("Area Of Rectangle = "+ area.compute(1,2));

Solution:

U
G

Explain the following:


a) packages
b) try and catch
c) Multithreading

TM

Q.5.

AO

area = tri;
System.out.println("Area Of Triangle = "+ area.compute(10,2));
}
}

W
C

a) packages: A package allows a developer to group classes (and interfaces) together. These
classes will all be related in some way they might all be to do with a specific application or
perform a specific set of tasks.
package battleships
class GameBoard{
}
Every class with the above package statement at the top will now be part of the Battleships
package.
In a Java source file, the package that this file's class or classes belong to is specified
with the package keyword. This keyword is usually the first keyword in source file.
package java.awt.event;

b) try and catch


Exceptions are a means of dealing with error conditions where in other languages, workaround
techniques need to be used such as reserving a special return value to indicate "error".
The try/catch statement encloses some code and is used to handle errors and exceptions that
might occur in that code. Here is the general syntax of the try/catch statement:
try {
body-code
} catch (exception-classname variable-name) {
handler-code
}
c) Multithreading :

AO

Multithreading is a technique that allows a program or a process to execute many tasks


concurrently (at the same time and parallel). It allows a process to run its tasks in parallel mode
on a single processor system

In the multithreading concept, several multiple lightweight processes are run in a single
process/task or program by a single processor. For Example, When you use a word
processor you perform a many different tasks such as printing, spell checking and so on.
Multithreaded software treats each process as a separate program.

W
C

TM

In Java, the Java Virtual Machine (JVM) allows an application to have multiple threads of
execution running concurrently. It allows a program to be more responsible to the user. When a
program contains multiple threads then the CPU can switch between the two threads to execute
them at the same time.
For example, look at the diagram shown as:

In this diagram, two threads are being executed having more than one task. The task of each
thread is switched to the task of another thread.
Advantages of multithreading over multitasking :

Q.6.

Reduces the computation time.


Improves performance of an application.
Threads share the same address space so it saves the memory.
Context switching between threads is usually less expensive than between processes.
Cost of communication between threads is relatively low.

Explain life cycle of applet.

Solution:

AO

A Java applet is an applet delivered to users in the form of Java bytecode. Java applets can run
in a Web browser using a Java Virtual Machine (JVM), or in Sun's AppletViewer, a stand-alone
tool for testing applets. Java applets were introduced in the first version of the Java language in
1995, and are written in programming languages that compile to Java bytecode, usually in Java.

init(): This method is called to initialized an applet

Applet runs in the browser and its lifecycle method are called by JVM when it is loaded and
destroyed. Here are the lifecycle methods of an Applet:

start(): This method is called after the initialization of the applet.


stop(): This method can be called multiple times in the life cycle of an Applet.

Q.7.

W
C

TM

destroy(): This method is called only once in the life cycle of the applet when applet is
destroyed.

(a) List and state all tags of HTML forms.

Solution:

HTML forms are used to pass data to a server.


A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons
and more. A form can also contain select lists, textarea, fieldset, legend, and label elements.
The <form> tag is used to create an HTML form:
<form>
input elements

</form>
The following elements can make up the user-inputting portion of a form:
input field

text a simple text box that allows input of a single line of text (an
alternative, password, is used for security purposes, in which the characters typed in are
invisible or replaced by symbols such as *)

checkbox a check box

radio a radio button

file a file select control for uploading a file

reset a reset button that, when activated, tells the browser to restore the values
to their initial values.

submit a button that tells the browser to take action on the form (typically to
send it to a server)
textarea much like the text input field except a textarea allows for multiple rows of data
to be shown and entered
select a drop-down list that displays a list of items a user can select from

Q.7.

(b) Describe Meta tags and semantic tags.

Metadata is information about data.

AO

TM

The <meta> tag provides metadata about the HTML document. Metadata will not be displayed
on the page, but will be machine parsable.

W
C

Meta elements are typically used to specify page description, keywords, author of the
document, last modified, and other metadata.
The <meta> tag always goes inside the head element.
The metadata can be used by browsers (how to display content or reload page), search engines
(keywords), or other web services.
<meta name="keywords" content="HTML, CSS, XML" />
Semantic HTML is the use of HTML markup to reinforce the semantics, or meaning, of the
information in webpages rather than merely to define its presentation (look). Semantic HTML is
processed by regular web browsers as well as by many other user agents. CSS is used to
suggest its presentation to human users.
Semantic HTML or semantic markup is HTML that introduces meaning to the web page rather
than just presentation.

Abbreviation

<blockquote>

Long quotation

<dfn>

Definition

<address>

Address for author(s) of the document

<code>

Code reference

<del>

Deleted text

<ins>

Inserted text

What do you mean by style sheet? Explain internal style specification within HTML.

AO

Q.8.

<abbr>

Solution:

Style sheets represent a major breakthrough for Web page designers, expanding their ability to
improve the appearance of their pages. In the scientific environments in which the Web was
conceived, people are more concerned with the content of their documents than the
presentation.

TM

The purpose of style sheets is to separate the content of the HTML documents from their style.
This makes control over the style much easier and group efforts easier since content of an
entire set of HTML pages can be easily controlled using one or more style sheets.

W
C

<html>
<head>
<title>Example Style Settings</title>
</head>
<style type="text/css">
Body
</style>
Internal Style Sheet

An internal style sheet is a section on an HTML page that contains style definitions. Internal
style sheets are defined by using the <style> tag within the <head> area of the document. Here
is an example of an internal style sheet:
<html>
<head>

What is client side programming? Explain java script object model.

AO

Q.9.

<title>Internal Style Sheet Example</title>


<style>
<!-body { background: #C9F1C5 }
h1 { color: #54B24B; font: bold 14px Verdana, Arial, Helvetica }
p { font: 12px Verdana, Arial, Helvetica }
-->
</style>
</head>
<body>
<h1>Page With an Internal Style Sheet</h1>
<p>This page contains style definitions at the top of the HTML code.</p>
</body>
</html>

Solution:

java script object model

TM

Client-side programming is run on the user's computer. An example of client-side programming


is Javascript. Javascript can be used to run checks on form values and send alerts to the user's
browser. The problem with client-side scripts is the limit of control and problems with operating
systems and web browsers. Since programming a website involves users with several options
of computer software, it's difficult for programmers to account for any bugs in the code or
compatibility issues with browsers.

W
C

Every web page resides inside a browser window which can be considered as an object.
A Document object represents the HTML document that is displayed in that window. The
Document object has various properties that refer to other objects which allow access to and
modification of document content.
The way that document content is accessed and modified is called the Document Object Model,
or DOM. The Objects are organized in a hierarchy. This hierarchical structure applies to the
organization of objects in a Web document.

Window object: Top of the hierarchy. It is the outmost element of the object hierarchy.
Document object: Each HTML document that gets loaded into a window becomes a
document object. The document contains the content of the page.
Form object: Everything enclosed in the <form>...</form> tags sets the form object.
Form control elements: The form object contains all the elements defined for that object
such as text fields, buttons, radio buttons, and checkboxes.

U
G

TM

Q.10. Describe the following:


a) Output in javaScript
b) Cookies
Solution:

AO

Here is a simple hierarchy of few important objects:

W
C

a) Output in javaScript
JavaScript is special from other languages because it can accept input and produce
output on the basis of that input in the same page. That mean, you don't have to go to
other page or refreash the page to see the output.
Functions to show output
1)window.alert():
2)window.status()
3)document.write()
1)window.alert(): This function show the message in a small messagebox . The
messagebox contains the string and an "OK"button on it. If the user presses the "OK"
button the messagebox dissapears. The message to be displayed has to be passed as
parameter window.alert() .
Code example :
<html>
<body>
<script language="Javascript">
window.alert ("Hello");

</script>
</body>
</html>
2)window.status(): This function show the message in statusbar . The message to be displayed
has to be passed as parameter window.status() .
Code example :

W
C

TM

<html>
<body>
<script language="Javascript">
document.write( "Welcome to JavaScript");
document.close();
</script >
</body>
</html>

AO

<html>
<body>
<script language="Javascript">
window.status ="Welcome to JavaScript";
</script >
</body>
</html>
3)document.write(): This function print a string in the current page. The message to be
displayed has to be passed as parameter document.write() .
Code example :

Q.11. Explain in brief Event handling in javaScript.


Solution:
JavaScript Event Handling
Events
By using JavaScript, we have the ability to create dynamic web pages. Events are actions that
can be detected by JavaScript.
Every element on a web page has certain events which can trigger a JavaScript. For example,
we can use the onClick event of a button element to indicate that a function will run when a user
clicks on the button. We define the events in the HTML tags.
Examples of events:

1.
2.
3.
4.
5.
6.

A mouse click
A web page or an image loading
Mousing over a hot spot on the web page
Selecting an input field in an HTML form
Submitting an HTML form
A keystroke

Event Handlers:
Use this to invoke JavaScript upon clicking (a link, or form boxes)

onload:

Use this to invoke JavaScript after the page or an image has finished loading.

onmouseover:

Use this to invoke JavaScript if the mouse passes by some link

onmouseout:

Use this to invoke JavaScript if the mouse goes pass some link

onunload:

Use this to invoke JavaScript right after someone leaves this page.

AO

onclick:

onLoad and onUnload

The onLoad and onUnload events are triggered when the user enters or leaves the page.

The onLoad event is often used to check the visitor's browser type and browser version, and
load the proper version of the web page based on the information.

W
C

TM

Both the onLoad and onUnload events are also often used to deal with cookies that should be
set when a user enters or leaves a page. For example, you could have a popup asking for the
user's name upon his first arrival to your page. The name is then stored in a cookie. Next time
the visitor arrives at your page, you could have another popup saying something like: "Welcome
John Doe!".
onFocus, onBlur and onChange
The onFocus, onBlur and onChange events are often used in combination with validation of
form fields.Below is an example of how to use the onChange event. The checkEmail() function
will be called whenever the user changes the content of the field:
<input type="text" size="30" id="email" onchange="checkEmail()">

onSubmit
The onSubmit event is used to validate ALL form fields before submitting it.

Below is an example of how to use the onSubmit event. The checkForm() function will be called
when the user clicks the submit button in the form. If the field values are not accepted, the
submit should be cancelled. The function checkForm() returns either true or false. If it returns
true the form will be submitted, otherwise the submit will be cancelled:
<form method="post" action="xxx.htm" onsubmit="return checkForm()">

onMouseOver

The onmouseover event can be used to trigger a function when the user mouses over an HTML
element:

AO

Example 1: onfocus event


<html>

<title>example of onfocus event handler</title>

<head>

</head>

TM

<body>

</script>
</head>
<body>

W
C

<script type="text/javascript">

<h3> onfocus event handler</h3>


<form>
<input type="text" onfocus='alert("you focused in the textbox")'></form>
</body>
</html>

Q.12. What is server side programming? Explain in brief Common gateway interface.
Solution:
Server-side scripting is a web server technology in which a user's request is verified by running
a script directly on the web server to generate dynamic web pages. It is usually used to provide
interactive web sites that interface to databases or other data stores.

CGI

W
C

TM

AO

Though it is technically feasible to implement almost any business logic using client side
programs, logically or functionally it carries no ground when it comes to enterprise applications
(e.g. banking, air ticketing, e-shopping etc.). To further explain, going by the client side
programming logic; a bank having 10,000 customers would mean that each customer should
have a copy of the program(s) in his or her PC which translates to 10,000 programs! In addition,
there are issues like security, resource pooling, concurrent access and manipulations to the
database which simply cannot be handled by client side programs. The answer to most of the
issues cited above is ? ?Server Side Programming?. Figure-1 illustrates Server side
architecture in the simplest terms.

When you are dealing with Web pages, you will often hear people talk about CGI or CGI scripts
without ever explaining exactly what that is. Essentially, CGI is the connection (or interface)
between a form on a Web page and the Web server.
Web pages cannot interact directly with the reader. In fact, until JavaScript came along, Web
pages had no way of interpreting reader reaction except through interaction with the server they
were running on. This interaction is done through scripts and programs that use common
gateway interface to create interactive programs on your Web pages.
GET -- the data are passed within the query string of the URL.

POST -- the data are sent as a message body that follows the request message sent by the
client to the server. This is more complex than GET, but allows for more complex data.
Q.13. Explain Active server pages and its advantages.
Solution:
Abbreviated as ASP, a specification for a dynamically created Web page with
a.ASP extension that utilizes ActiveX scripting -- usually VB Script or Jscriptcode. When
a browser requests an ASP, the Web server generates a page with HTML code and sends it
back to the browser. So ASPs are similar to CGIscripts, but they enable Visual Basic
programmers to work with familiar tools

Q.14. Explain form processing VB Script and JavaScript.

AO

Solution:
//Form processing using javascript

<HTML>

<HEAD>

function testResults (form) {

<SCRIPT LANGUAGE="javascript">

<TITLE>Test Input</TITLE>

TM

var TestVar = form.inputbox.value;

}
</SCRIPT>
</HEAD>

W
C

alert ("You typed: " + TestVar);

<BODY>
<FORM NAME="myform" ACTION="" METHOD="GET">Enter something in the box: <BR>
<INPUT TYPE="text" NAME="inputbox" VALUE=""><P>
<INPUT TYPE="button" NAME="button" Value="Click" onClick="testResults(this.form)">
</FORM>
</BODY>

</HTML>
//Form processing using VBScript
<HTML>
<HEAD>
<TITLE>Date/Time Example</TITLE>
</HEAD>
<BODY>

<CENTER>

AO

<H3> Welcome to my Web page! </H3>


<FORM NAME="frmMyForm">

<INPUT TYPE=text NAME="timeinfo">

<INPUT TYPE=button VALUE="Update Time" NAME="btnTime">

</FORM>

Sub btnTime_OnClick

TM

frmMyForm.timeinfo.value = Now

<SCRIPT LANGUAGE="vbscript">

End Sub
</SCRIPT>
</BODY>

W
C

frmMyForm.timeinfo.value = Now

</HTML>

Q.15. Discuss the following:


a) VRML
b) PERL
a) VRML
Solution:

Pronounced ver-mal, and short for Virtual Reality Modeling Language, VRML is a specification
for displaying 3-dimensional objects on the World Wide Web. You can think of it as the 3-D
equivalent of HTML. Files written in VRML have a.wrl extension (short for world). To view these
files, you need a VRMLbrowser or a VRML plug-in to a Web browser.
VRML produces a hyperspace (or a world), a 3-dimensional space that appears on your display
screen. And you can figuratively move within this space. That is, as you press keys to turn left,
right, up or down, or go forwards or backwards, the images on your screen will change to give
the impression that you are moving through a real space.
VRML 1.0
This is the first generation of VRML.

AO

VRML 1.0 is designed to meet the following requirements:

It describes the foundations of a world including geometry, lighting, color, texture and linking.

Platform independence

Extensibility

TM

VRML 2.0

No support for interactive behaviors

Ability to work well over low-bandwidth connections

W
C

This is the current generation of VRML.


It has a richer level for interactivity and includes support for animation, spatial sound and
scripting in addition to features that are already supported in VRML 1.0.
VRML Architecture Board made it official in March 1996
b) PERL:
Perl is a programming language which can be used for a large variety of tasks. A typical simple
use of Perl would be for extracting information from a text file and printing out a report or for
converting a text file into another form. But Perl provides a large number of tools for quite
complicated problems, including systems programming.
Programs written in Perl are called Perl scripts, whereas the term the perl program refers to the
system program named perl for executing Perl scripts. (What, confused already?)

If you have used shell scripts or awk or sed or similar (Unix) utilities for various purposes, you
will find that you can normally use Perl for those and many other purposes, and the code tends
to be more compact. And if you haven't used such utilities but have started thinking you might
have need for them, then perhaps what you really need to learn is Perl instead of all kinds of
futilities.
Perl is implemented as an interpreted (not compiled) language. Thus, the execution of a Perl
script tends to use more CPU time than a corresponding C program, for instance. On the other
hand, computers tend to get faster and faster, and writing something in Perl instead of C tends
to save your time.

Q.16. Discuss the contribution of Applets and Servlets to web development.

AO

Solution:
Java Applets

Java is an object-oriented programming language developed by Sun Microsystems


(http://www.sun.com). It should be noted that it is not related to JavaScript, which is a scripting
language developed by Netscape Navigator to run within an HTML document in a browser.
Because Java is a full programming language (like C or C++), it can be used to create whole
applications.

TM

Java's primary contribution to the Web, however, has been in the form of Java applets, which
are self-contained, mini-executable programs. These programs, named with the .class suffix,
can be placed right on the web page, like a graphic.

W
C

12.6.1. Advantages and Disadvantages


Applets are ideal for web distribution for the following reasons:

They are platform-independent.


They download completely and run on the client, so there is no continued burden on the
server.
Applet files are generally quite compact and download quickly.
They don't require a proprietary plug-in to be installed. All the major browsers are now
Java-enabled, which means chances are good that users will be able to view the applet.

Java Servlets

When compared to the Common Gateway Interface (CGI) and proprietary server
extensions such as Netscape Server API (NSAPI) or Microsofts Internet Services API
(ISAPI), servlets provide a better abstraction of the Hypertext Transfer Protocol (HTTP)
request-response paradigm. In addition, servlets have all the advantages of the Java
programming language, including platform independence. Java servlet based
applications can be deployed on any web server with built-in (in-process) or connectorbased (out-of-process) servlet engines, irrespective of the operating system and the
hardware platform. This is one of the reasons for servlets gaining wide acceptance over
the past one year.

TM

AO

Java servlets are small, platform independent server-side programs that


programmatically extend the functionality of the web server. The Java servlet API
provides a simple framework for building applications on web servers. This API is
described in the Java Servlet API Specification (currently version 2.1) by the Java
Software Division of Sun Microsystems Inc.
Java servlets are not user-invocable applications. Servlets interact with a servlet engine
(an implementation of the Java Servlet API specification) through requests and
responses. The servlet engine in-turn interacts with the web server by delegating
requests to servlets and transmitting responses to the web server.

Q.17. Explain Cookies in brief.

W
C

Solution:

What are cookies?

Cookies are small amounts of data stored by the web browser. They allow you to store
particular information about a user and retrieve it every time they visit your pages. Each user
has their own unique set of cookies.
Cookies are typically used by web servers to perform functions such as tracking your visits to
websites, enabling you to log in to sites, and storing your shopping cart. However we don't need
fancy web server programming to use cookies. We can use them in JavaScript, too!
How Cookies work
A Cookies is nothing but a small text file thats stored in your browser. It contains some data:

1. A Name value pair containing the actual data


2. An expiry date after which it is no longer valid
3. The domain and path of the server it should be sent to
A java script cookies is a document object.
The document.cookie property
Cookies in JavaScript are accessed using the cookie property of the document object. In simple
terms, we create a cookie like this:
document.cookie = "name=value; expires=date; path=path;

These properties are explained in the table below:

var x = document.cookie;

AO

...and retrieve all our previously set cookies like this:

domain=domain; secure";

Description

name=value

This sets both the cookie's name and its value.

username=matt

expires=date

This optional value sets the date that the


cookie will expire on. The date should be in
the format returned by the
toGMTString() method of the Dateobject. If
the expires value is not given, the cookie will
be destroyed the moment the browser is
closed.

expires=
13/06/2003 00:00:00

This optional value specifies a path within the


site to which the cookie applies. Only
documents in this path will be able to retrieve
the cookie. Usually this is left blank, meaning
that only the path that set the cookie can
retrieve it.

path=/tutorials/

W
C

TM

Property

path=path

domain=domain

This optional value specifies a domain within


which the cookie applies. Only websites in this
domain will be able to retrieve the cookie.
Usually this is left blank, meaning that only the

Example

domain=elated.com

domain that set the cookie can retrieve it.


Let's look at a few examples of cookie setting:
document.cookie = "username=John;
expires=15/02/2003 00:00:00";
This code sets a cookie called

Q.18. Give a brief description of Microsoft .net technology and discuss how it is better than
other technologies?

AO

Solution:

TM

W
C

A Microsoft operating system platform that incorporates applications, a suite of tools and
services and a change in the infrastructure of the company's Web strategy.
There are four main principles of .NET from the perspective of the user:
It erases the boundaries between applications and the Internet. Instead of interacting
with an application or a single Web site, .NET will connect the user to an array of computers and
services that will exchange and combine objects and data.
Software will be rented as a hosted service over the Internet instead of purchased on a
store shelf. Essentially, the Internet will be housing all your applications and data.
Users will have access to their information on the Internet from any device, anytime,
anywhere.
There will be new ways to interact with application data, such as speech and handwriting
recognition.
Reasons Why dotNET Is Better Than Java
1- In .NET you have a choice of languages to code with (C#,VB.NET, Java,Boo,Python e.t.c),
producing the same type of compiled code but in Java one is limited to the java
language..

2, NET prgrams run at native speed while java is interpreted which makes java slower.Although
java has Just In Time compilation but it stills run slower. With .NET you are not limited to
JIT but have the option AOT or ahead of time compilation if you want to eliminate startup
delays.

3. Calling native code in java is not a very clean process. You need to generate some stub files
which makes the whole process cumbersome and dirty. In .NET you just declare that
you are calling a native function from a specified library and just start calling it.

4. .NET languages are richer than Java. They have object oriented feature that are absent in
java e.g properties,delegates,generics.

5. Java GUI programs look alien on the host operating system. Even if you use the OS's theme
you still notice that the java widgets look out of place.

AO

6. Many programs that would have been difficult to develop with java have been developed with
.NET things like compilers (Mono's C# and VB.NET) 3D game engines (unity game
engine) etc.

W
C

TM

Q.19. Discuss the following:


a) World Wide Web
b) XML
a) World Wide Web:
Solution:

7. You can code on the .NET platform using Java but you cannot code on Java platform using
any of the .NET languages.

A system of Internet servers that support specially formatted documents. The documents are
formatted in a markup language called HTML (HyperText Markup Language) that supports links
to other documents, as well asgraphics, audio, and video files. This means you can jump from
one document to another simply by clicking on hot spots. Not all Internet servers are part of the
World Wide Web.
There are several applications called Web browsers that make it easy toaccess the World Wide
Web; Two of the most popular being Firefox andMicrosoft's Internet Explorer.
The Internet
The Internet, on the technological level, consists of the wires, cables, machines, and networking
software which connects millions of computers around the world. This complex infrastructure of
computer networks is the pavement of the "Information Superhighway" that allows web

browsers to communicate with servers, request, send, and receive information from around the
world, regardless of global location.
Information Servers
Information servers run on computers connected to the Internet all over the world. Information
servers are processes (executing computer software) which dish out information as requested
from users connected to the same network (in the case of the WWW, the public Internet). The
most common information types of servers on the Internet today are:

World Wide Web servers;


Gopher servers
FTP, or FileTransport Protocol Servers;

AO

Extensible Markup Language (XML) is a set of rules for encoding documents in machinereadable form. It is defined in the XML 1.0 Specification produced by the W3C, and several
other related specifications, all gratis open standards

W
C

TM

Q.20. Explain the following:


a) XHTML
b) W3C
Solution:

The design goals of XML emphasize simplicity, generality, and usability over the Internet.[6] It is
a textual data format with strong support via Unicode for the languages of the world. Although
the design of XML focuses on documents, it is widely used for the representation of arbitrary
data structures, for example in web services.

XHTML (eXtensible HyperText Markup Language) is a family of XML markup languages that
mirror or extend versions of the widely-used Hypertext Markup Language (HTML), the language
in which web pages are written. XHTML is an application of XML, a more restrictive subset of
SGML. Because XHTML documents need to be well-formed, they can be parsed using standard
XML parsers unlike HTML, which requires a lenient HTML-specific parser.

The World Wide Web Consortium (W3C) is an international community where Member
organizations, a full-time staff, and the public work together to develop Web standards

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy