Sie sind auf Seite 1von 13

MC5303 WEB PROGRAMMING ESSENTIALS

1. What is WWW and HTTP?


 WWW stands for World Wide Web. 
 The World Wide Web is the universe of network-accessible information, an embodiment
of human knowledge
 The Hyper Text Transfer Protocol (HTTP) is a communication protocol used to transfer
the information on local area networks and www.

2. Distinguish between Static and Dynamic Web Pages.


Static web pages are also known as flat or stationary web page.
They are loaded on the client’s browser as exactly they are stored on the web server.
User can only read the information but can’t do any modification or interact with the
information
Dynamic web page shows different information at different point of time.
It is possible to change a portion of a web page without loading the entire web page.

3. Define Hyperlink.
It is a link that allows user to navigate (jump) from one document to another document
quickly. Using hyperlink, to save time complexity.
Hyperlink is highlighted and change to hand symbol, when mouse pointer moves over
hyperlink.
In html page hyperlinks are defined with text or images that always refer are multimedia
effort (audio, video), that always refer existing document, internet resource files.
<A> anchor It defining link to html document.
<a> -------- </a>
< a href = “URL”>.
href attribute represents the URL of document, that contain between (Text or image). A tag
is referred as hyperlink.

4. How will you embed the External Style Sheet in HTML?


The <link> tag is the key to adding a External CSS reference to an HTML document. 
Example:

<link rel = "stylesheet"


type = "text/css"
href = "myStyle.css" />

5. Write a simple program in JavaScript to validate the email id.


<script type="text/javascript">
function validateEmail(email)
{
var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
if (reg.test(email)){
return true; }
else{
return false;
}
}
</script>
1
6. How to write functions using JavaScript ? Give example.
A JavaScript function is defined with the function keyword, followed by a name, followed by
parentheses ().
Function names can contain letters, digits, underscores, and dollar signs
The parentheses may include parameter names separated by commas:
(parameter1, parameter2, ...)
The code to be executed, by the function, is placed inside curly brackets: {}
Example:
function myFunction(p1, p2)
{
  return p1 * p2;   // The function returns the product of p1 and p2
}

7. What is Object Constructor?


Object constructor: In JavaScript, there is a special constructor function known as Object() is
used to create and initialize an object. The return value of the Object() constructor is
assigned to a variable. The variable contains a reference to the new object. We need an
object constructor to create an object “type” that can be used multiple times without
redefining the object every time.
Example:
function GFG(A, B, C) {
this.g = A;
this.f = B;
this.gg = C;
}
Here, GFG is the constructor name and A, B, C are the arguments of the constructor.
Instantiating an object constructor: There are two ways to instantiate object constructor,
var object_name = new Object(); or
var object_name = new Object("java", "JavaScript", "C#");
var object_name = { };

8. List out the Advantages of AJAX.


 Asynchronous Java script And XML
 Ajax is not a programming language.
 Ajax is a methodology
 Web development technique for creating web applications
 Makes web pages more responsive by exchanging small amounts of data
 Ajax allows the developer to exchange the data with the server and updates the part of
web document without reloading the web page.
 A web browser technology independent of web server software.
Examples
Google Maps , Google Suggest, Windows Live Local, Windows Live Mail (Hotmail Beta)

9. When print/echo statement used in PHP?


Values can be displayed (output) using three methods: echo,  print(), and printf()
print and echo are used to print to the browser
echo "Go Bisons";
echo("Go Bisons"); // same thing
print("Go Bisons"); // same thing.
print can only accept one argument, and echo can accept any number of arguments.
print returns a value that indicates if the print statement succeeded.
2
10. Write down the general syntax for each looping structure in PHP.

for while do while For each


for (initialization; while (condition) do foreach (array as
condition; { { value)
increment) code to be code to be {
{ executed; executed; code to be
code to be } }while (condition); executed;
executed; }
}

10. What is File Transfer Protocol?


FTP - This stands for File Transfer Protocol.
This is a popular way to transfer files from machine to machine across a network.
File Transfer Protocol (FTP) is the standard mechanism provided by TCP/IP for copying a
file from one host to another.
FTP uses the services of TCP.

11. What is need for CSS?


a. Separation : CSS allows separation between the information contained in a document
and its presentation. Hence any change in the presentation can be made without
disturbing the information of the document.
b. Persistent : Style sheet allow users to decide the style of presentation. This presentation
style can be defined in a separate file. Thus the presentation can be made persistent.
c. Consistent appearance : CSS allows the developer to give the consistent appearance
to all the elements of the web page.
d. Consistent look and feel : If we use single style sheet for all the pages of the web site
then all the pages will have a consistent look and feel.
e. Precise control : CSS provides precise control over font size, color, background color
and so on.

12. What are the important features of Javascript?


 JavaScript can be used as an alternative to Java applets.
 JavaScript can get embedded in XHTML.
 JavaScript can be effectively used for interaction with the users.
 Using Document Object Model(DOM) JavaScript can access and modify the properties
of CSS(Cascading Style Sheets) and contents of XHTML document.
 JavaScript can be used to detect the visitor’s browsers and can load the page
accordingly.
 JavaScript can be used to create cookies.
 JavaScript are used to validate the data on the web page before submitting it to the
server.

13. Define Event Handling.


Event handling is a script that gets executed in response to these events. Thus event
handler enables the web document to respond the user activities thorough the browser
window.
Events are specified in lowercase letters and these are case-sensitive.
The process of connecting event handler to an event is called event registration. The event
handler registration can be done using two methods:

3
(i) Assigning the tag attributes
In this method the event handler code can be assigned to the attribute of an element.
Example : Element.onclick=my_fun;
That means when user clicks on the element the event hander function my fun() will be
called. Note that we must not use parenthesis while specifying the function my_fun.

(ii)Assigning the handler address to object properties.


In this method name of the event handler is assigned to the property associated with the
event.
Example : <input type=”button” value=”Enter” onclick=”my_fun();”/>
Thus the onclick becomes the property of the button element to which the event handler
code is assigned. Hence on clicking the button, the code for my_fun() will get invoked as
the event handler.

14. What do you mean by media management?


Media Management allows to view and manipulates our digital assets.
There are methods for loading, playing, pausing, and jumping to a time. There are also
properties we can set programmatically, such as the src URL and the height and width of a
video, as well as read-only properties such as the video’s native height. Finally, there are
DOM events we can listen for, such as load progress, media playing, media paused, and
media done playing.

15. List out the various types of operators in PHP.


Operators are used to operate on values. There are four classifications of operators:
Arithmetic + - * / %
Assignment = += -= /= *= %= ++ -- .
Comparison == != < > <= >=
Logical && || !

16. What are the uses of PHP?


Open-source, server-side scripting language
Used to generate dynamic web-pages
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL,
Generic ODBC, etc.)
PHP is free to download and use
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)

17. Differentiate between client-side scripting and server side scripting.


Client-side: It is a collection of objects using which one can have control over the browser
interaction is possible.
Server-side: It is a collection of objects using which one can access the database on the
server.
18. What is difference between hostpot and hyperlink?
A hotspot is basically a "spot" on an image map and can be linked to whatever we want to
link it to using a hyperlink. A hyperlink uses the tags and can be a text or image link.

19. Write JavaScript to display current time on the status bar..

< HTML>

4
<HEAD>
<TITLE>Status Bar Clock</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var flasher = false
// calculate current time, determine flasher state,
// and insert time into status bar every second
function updateTime() {
var now = new Date()
var theHour = now.getHours()
var theMin = now.getMinutes()
var theTime = "" + ((theHour > 12) ? theHour - 12 : theHour)
theTime += ((theMin < 10) ? ":0" : ":") + theMin
theTime += (theHour >= 12) ? " pm" : " am"
theTime += ((flasher) ? " " : "*")
flasher = !flasher
window.status = theTime
// recursively call this function every second to keep timer going
timerID = setTimeout("updateTime()",1000)
}
//-->
</SCRIPT>
</HEAD>
<BODY onLoad="updateTime()">
</BODY>
</HTML>

20. Name and mention the use of any four methods in JavaScript Math object.

The JavaScript math object provides several constants and methods to perform mathematical


operation.
Methods Description
abs() It returns the absolute value of the given number.
cbrt() It returns the cube root of the given number.
ceil() It returns a smallest integer value, greater than or equal to the given
number.
cos() It returns the cosine of the given number.
cosh() It returns the hyperbolic cosine of the given number.
exp() It returns the exponential form of the given number.
pow() It returns value of base to the power of exponent.

21. Define the super classes and subclasses with example.


Every class can have a super class from which it inherits properties and methods. Any class
can be extended, or sub-classed so the resulting subclass can inherit its parent's behavior.
JavaScript supports prototype inheritance instead of class based. It's possible for inheritance to
happen other ways, however.
Example:
<script language="javascript" type="text/javascript">
<!--

function superClass() {
5
this.supertest = superTest; //attach method superTest
}

function subClass() {
this.inheritFrom = superClass;
this.inheritFrom();
this.subtest = subTest; //attach method subTest
}

function superTest() {
return "superTest";
}

function subTest() {
return "subTest";
}

var newClass = new subClass();

alert(newClass.subtest()); // yields "subTest"


alert(newClass.supertest()); // yields "superTest"

//-->
</script>

22. State how web works.

23. What are the PHP Array operators?


We can perform operations on arrays using Arrays Operators like Union, Equality, Identity,
Inequality and Non-identity.

Operator Name Example


+ Union $x + $y
== Equality $x == $y
=== Identity $x === $y
!= Inequality $x != $y
<> Inequality $x <> $y
!== Non-identity $x !== $y

24. What are the two commonly used port numbers and its purpose in FTP

6
 Control connection - For sending control information like user identification, password,
commands to change the remote directory, commands to retrieve and store files etc., FTP
makes use of control connection. Control connection is initiated on port number 21.

 Data connection - For sending the actual file, FTP makes use of data connection. Data
connection is initiated on port number 20.

25. State the purpose of SMTP and POP3 protocols in Email Sercive.
 Simple Mail Transfer Protocol (SMTP) is the standard protocol for sending emails across
the Internet.
 Post Office Protocol version 3 (POP3) is a standard mail protocol used to receive
emails from a remote server to a local email client. POP3 allows to download email
messages on our local computer and read them even when you are offline.

26. How an email address are linked with the html pages?
HTML <a> tag provides you option to specify an email address to send an email. While
using <a> tag as an email tag,
Example: a href = "mailto: abc@example.com">Send Email</a>

27. How to create transparent images with CSS?


The opacity property specifies the opacity/transparency of an element.
Example:
img
{
  opacity: 0.5;
  filter: alpha(opacity=50); /* For IE8 and earlier */
}
28. What are the global functions in JavaScript?
The JavaScript global properties and functions can be used with all the built-in JavaScript
objects.

Function Description
decodeURI() Decodes a URI
encodeURI() Encodes a URI
eval() Evaluates a string and executes it as if it was script code
isFinite() Determines whether a value is a finite, legal number
isNaN() Determines whether a value is an illegal number
Number() Converts an object's value to a number
parseFloat() Parses a string and returns a floating point number
parseInt() Parses a string and returns an integer
String() Converts an object's value to a string

29. What is document object model?


.
 DOM is a set of platform independent and language neutral application programming
interface (API).
 It describes how to access and manipulate the information stored in XML,XHTML and
other scripting languages.
 The DOM represents a document with a logical tree. Each branch of the tree ends in a
node, and each node contains objects. DOM methods allow programmatic access to the
tree; with them one can change the structure, style or content of a document. 

7
The DOM tree will be, root
Document

parent node

<head> <body> node

siblings

child node
<title> <h1> <h2 <h3>
leaf nodes >

This is my web page “Hello” “How are you” “See you”

30. What is object constructor and prototyping in JavaScript?

Object constructor:  In JavaScript, there is a special constructor function known


as Object() is used to create and initialize an object. The return value of
the Object() constructor is assigned to a variable. The variable contains a reference to the
new object. We need an object constructor to create an object “type” that can be used
multiple times without redefining the object every time.
Example:
function GFG(A, B, C)
{
this.g = A;
this.f = B;
this.gg = C;
}
Here, GFG is the constructor name and A, B, C are the arguments of the constructor.
Instantiating an object constructor: There are two ways to instantiate object constructor,
var object_name = new Object(); or
var object_name = new Object("java", "JavaScript", "C#");
var object_name = { };
Prototyping: In JavaScript, each Object can inherit properties from another object, called
it's prototype. When evaluating an expression to retrieve a property, JavaScript first looks to
see if the property is defined directly in the object. If it is not, it then looks at the object's
prototype to see if the property is defined there. This continues up theprototype chain until
reaching the root prototype. Each object is associated with a prototype which comes from
the constructor function from which it is created.
For example, if we want to create an object, X, from constructor function B, whose
prototype chain is: B.prototype, A.prototype, Object.prototype

31. Mention the two data structures in JSON?


JSON supports two widely used (amongst programming languages) data structures.
A collection of name/value pairs. Different programming languages support this data
structure in different names. Like object, record, struct, dictionary, hash table, keyed list, or
associative array.
An ordered list of values. In various programming languages, it is called as array,
vector, list, or sequence.
32. How to embed the PHP code in HTML?
PHP source code is embedded in an HTML-based document, and is identified by
special delimiting tags.
<?php   content   ?>

8
<h2>My Webpage</h2>
This is my webpage.

<?php
echo "This is written in PHP.\n";
?>

33. Demonstrate different ways of connecting MySQL with PHP.


 Connect using mysqli extension
 Connect using PDO
 Connect using traditional legacy mysql_ functions

34. What is the difference between relative and absolute positioning?

a. relative – relative position according to where the element would appear with static
position
b. absolute – position according to the innermost positioned parent element
Example:
H1
{
position: absolute; top: 100px; left: 200px;
}
35. Define: Markup language.
Markup languages are designed for the processing, definition and presentation of text.
The language specifies code for formatting, both the layout and style, within a text file. The
code used to specify the formatting are called tags.

36. What are the core features of JavaScript.


 JavaScript is a object-based scripting language.
 Giving the user more control over the browser.
 It Handling dates and time.
 It Detecting the user's browser and OS,
 It is light weighted.
 JavaScript is a scripting language and it is not java.
 JavaScript is interpreter based scripting language.
 JavaScript is case sensitive.

37. What are the features of PHP?


It is most popular and frequently used world wide scripting language, the main reason of
popularity is; It is open source and very simple.
 Faster
 Interpreted
 Case Sensitive
 Simplicity
 Efficiency
 Platform Independent
 Security
 Flexibility
 Familiarity
 Error Reporting

9
 Loosely Typed Language
 Real-Time Access Monitoring

38. What are the software components in LAMP?


Linux - operating system, 
Apache - Web server,
  MySQL - Relational database management system
  PHP - Object-Oriented Scripting Language.

39.What is POP3?
Post Office Protocol 3. is a simple, standardized method of delivering e-mail messages. A
POP3 mail server receives e-mails and filters them into the appropriate user folders. When
a user connects to the mail server to retrieve his mail, the messages are downloaded from
mail server to the user's hard disk.

40. Which tag is used for inserting an image in a web page?


<img> tag: - It display image as content of page. It content only begins tag. It has empty
content. It carries no data. It is dependent element. It has some following attribute.
src attribute: - It represent the URL image file.
Example:
<html>
<body>
<img src=“c:/photo/picture.jpeg”>
</body>

41. What are the limitations of JavaScript?


Client-side JavaScript does not allow the reading or writing of files.
It cannot be used for networking applications because there is no such support available.
It doesn't have any multithreading or multiprocessor capabilities.

42. What is JSON?


JSON stands for JavaScript Object Notation
JSON is lightweight data interchange format.
JSON is language independent 
JSON is "self-describing" and easy to understand
The JSON syntax is derived from JavaScript object notation syntax, but the JSON format is text
only. Code for reading and generating JSON data can be written in any programming language.

43. Define: PHP.


PHP == ‘Hypertext Preprocessor’
Open-source, server-side scripting language
Used to generate dynamic web-pages
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic
ODBC, etc.)
PHP is free to download and use
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)

44. Write the functions of HTTP request and response messages.


An HTTP request is a way that web browsers ask for information to load website pages. HTTP
request contains HTTP version type, a URL, HTTP request headers and HTTP body.
10
An HTTP response means when the web client gets the answer back from the web server. It
contains the information that was asked for in the HTTP request. HTTP response contains an
HTTP status code, HTTP response headers, and HTTP body.

45. What is an anchor in HTML? Give an example.


HTML uses the <a> anchor tag to create a link to another document or web page.
An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a
movie, etc. The syntax of creating an anchor:

<a href="url">Text to be displayed</a>

The <a> tag is used to create an anchor to link from, the href attribute is used to tell the
address of the document or page we are linking to, and the words between the open and
close of the anchor tag will be displayed as a hyperlink.

Code Would Display


<a href="http://www.aamec.edu/">Visit Delhi</a> Visit Delhi!

46. Distinguish between over loading and overriding.

Method Overloading Method Overriding


Method overloading is used to increase Method overriding is used to provide the
the readability of the program. specific implementation of the method
that is already provided by its super
class.
Method overloading is performed within Method overriding occurs in two
class. classes that have IS-A (inheritance)
relationship.
In case of method overloading, parameter In case of method overriding, parameter
must be different. must be same.
Method overloading is the example Method overriding is the example of run
of compile time polymorphism. time polymorphism.

47. What are default arguments in PHP?


HP allows you to define C++ style default argument values. In such case, if we don't pass any
value to the function, it will use default argument value.
Example
<?php  
function sayHello($name="Ram"){  
echo "Hello $name<br/>";  
}  
sayHello("Sonoo");  
sayHello();//passing no value  
sayHello("Vimal");  
?>  
48. State the different ways to use constants in PHP?
PHP constants are name or identifier that can't be changed during the execution of the script.
PHP constants can be defined by two ways:
1. Using define() function
2. Using const keyword

11
define("PI", 3.14);
define("HEADING", "<h1>My Web Site</h1>");

49. Distinguish between Get and Post method.


 GET Method - A GET Requests data from a specified resource using a given URI to retrieve
data.
 POST Method - A POST request Submits data to be processed to a specified resource to
the server.

50.What is the purpose of style tag?


The HTML <style> tag is used for declaring style sheets within the head of our HTML
document.
Example
<head>
<style type="text/css">
h1 { color:#F1F1F1 }
</style>
</head>

51. What is meant by type of operator? Give an example.


The typeof operator is used to get the data type (returns a string) of its operand. The operand
can be either a literal or a data structure such as a variable, a function, or an object. The
operator returns the data type.
Syntax
typeof operand
or
typeof (operand)

There are six possible values that typeof returns: object, boolean, function, number, string, and
undefined.

52. Differentiate slice and splice methods in array.


 The splice() method returns the removed item(s) in an array and slice() method returns the
selected element(s) in an array, as a new array object.
 The splice() method changes the original array and slice() method doesn’t change the
original array.
53. What is meant by ready State property?
 ReadyState identifies the loading status of a document.
 Used by developers to interact with page at certain loading states.
 Used as notable reference events by performance tools and APIs.
 This metric is reported by browsers.
 Document.readyState has three possible states. It tells u if a document is loading, interactive
or complete.

54.Define: Polymorphism.
The polymorphism is a core concept of an object-oriented paradigm that provides a way to
perform a single action in different forms. It provides an ability to call the same method on
different JavaScript objects. As JavaScript is not a type-safe language, we can pass any type of
data members with the methods.

12
Example
<script>  
class A  
   {  
      display()  
     {  
       document.writeln("A is invoked");  
     }  
   }  
class B extends A  
   {  
   }  
var b=new B();  
b.display();  
</script>  

55. What is LAMP server?


Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a
Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as
the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often
substituted for PHP.

56. List out the various array types in PHP.


In PHP, there are three types of arrays:
 Indexed arrays - Arrays with a numeric index
 Associative arrays - Arrays with named keys
 Multidimensional arrays - Arrays containing one or more arrays

57. Define Web Browser.


A web browser is a software program that allows a user to locate, access, and display web
pages. In common usage, Browsers are used primarily for displaying and accessing
websites on the internet, as well as other content created using languages such as
Hypertext Markup Language (HTML) and Extensible Markup Language (XML).
The most popular browsers are Chrome, Firefox, Safari, Internet Explorer, and Edge.

58. What is php superglobals?


Several predefined variables in PHP are "superglobals“.
It means they are available in all scopes throughout a script.
There is no need to do global $variable; to access them within functions or methods

59. What is the use of JSON?


 JSON is a light weight data format that can be used for transferring medium amounts of
data.
 It can be used in Java Script and then rendered on HTML pages.
 AJAX has many applications for JSON
 Thus, use JSON for applications that are browser based.

60. How to use JQuery?


 jQuery function - refers to the global jQuery object or the $ function depending on the
context.
 jQuery object - the object returned by the jQuery function that often represents a group of
elements.

13

Das könnte Ihnen auch gefallen