Big-d Internet Programming
Big-d Internet Programming
1. What is HTML?
a) HTML describes the structure of a webpage
b) HTML is the standard markup language mainly used to create web pages
c) HTML consists of a set of elements that helps the browser how to view the content
d) All of the mentioned
View Answer
Answer: d
Explanation: HTML is the standard markup language mainly used to create web pages.
HTML describes the structure and layout of a webpage. HTML consists of a series of
elements that helps the browser how to display content easily.
2. Who is the father of HTML?
a) Rasmus Lerdorf
b) Tim Berners-Lee
c) Brendan Eich
d) Sergey Brin
View Answer
Answer: b
Explanation: Timothy John Berners-Lee (TimBL) is known as the father of HTML. He is a
British computer scientist, best known as the inventor of the World Wide Web.
3. HTML stands for __________
a) HyperText Markup Language
b) HyperText Machine Language
c) HyperText Marking Language
d) HighText Marking Language
View Answer
Answer: a
Explanation: HTML stands for “HyperText Markup Language”. HTML is the standard
markup language mainly used to design and create web pages and web applications.
4. What is the correct syntax of doctype in HTML5?
a) </doctype html>
b) <doctype html>
c) <doctype html!>
d) <!doctype html>
View Answer
Answer: d
Explanation: The correct syntax of HTML5 doctype is <!doctype html>, doctype is the
very first thing to write in HTML5. <!doctype html> or <!DOCTYPE HTML> both are
same because ‘doctype’ keyword is not case sensitive.
5. Which of the following is used to read an HTML page and render it?
a) Web server
b) Web network
c) Web browser
d) Web matrix
View Answer
Answer: c
Explanation: A web browser (commonly referred to as a browser) is a software
application for retrieving, presenting and traversing information resources on the World
Wide Web. A web server process, store and display output to the client as per their
request. Web matrix is a discontinued cloud-connected website builder and HTML editor
for Windows.
advertisement
6. Which of the following is not a difference between HTML and XHTML?
a) Charset in both html and xhtml is “text/html”
b) Tags and attributes are case-insensitive in HTML but not in XHTML
c) Special characters must be escaped using character entities in XHTML unlike HTML
d) Charset in html is “text/html” where as in xhtml it is “application/xml+xhtml”
View Answer
Answer: a
Explanation: HTML is case insensitive while XHTML is case sensitive. In XHTML,
special characters can be escaped using character entites but not in HTML. Charset in
HTML is “text/html” where as it is “application/xml+xhtml” for XHTML.
7. Which of the following tag is used for inserting the largest heading in HTML?
a) head
b) <h1>
c) <h6>
d) heading
View Answer
Answer: b
Explanation: Headings in HTML starts from <h1> to <h6> in which <h1> heading is the
largest one and <h6> is smallest one among those. The heading tags are <h1> <h2>
<h3> <h4> <h5> and <h6> that are used for the creations of headings.
8. What is DOM in HTML?
a) Language dependent application programming
b) Hierarchy of objects in ASP.NET
c) Application programming interface
d) Convention for representing and interacting with objects in html documents
View Answer
Answer: d
Explanation: The Document Object Model is a cross-platform and language-independent
application programming interface that treats an HTML, XHTML, or XML document as a
tree structure. A document can be viewed as a logical tree with help of DOM Model.
9. In which part of the HTML metadata is contained?
a) head tag
b) title tag
c) html tag
d) body tag
View Answer
Answer: a
Explanation: Metadata is information about data. The meta tag provides metadata/meta
information about the HTML document. Metadata will not be displayed on the page.
Metadata is present in head. The body tag defines document’s body. A title tag is an
HTML element which specifies the title of a web page.
10. Which element is used to get highlighted text in HTML5?
a) <u>
b) <mark>
c) <highlight>
d) <b>
View Answer
Answer: b
Explanation: The <mark> element is used to highlight a section of text. It is useful for
quoting a text or if one wants to bring attention to the text. The <b> tag is used to make
text/paragraph bold. <u> tag is used to underline the text you wanted.
<p>This is the example.<mark> I like this dog. </mark></p>
b)
<img src="https://www.sanfoundry.com/sanfoundry-logo">
<a href="https://www.sanfoundry.com/">Sanfoundry Home Page</a>
</img>
c)
d)
<a href="https://www.sanfoundry.com/"><img
src="https://www.sanfoundry.com/sanfoundry-logo" /></a>
View Answer
Answer: d
Explanation: <a> tag defines a hyperlink, which is used to link from one page to another
page. Suppose if we want an image to be clickable then it should go inside <a> Tag.
Output:
Sanfoundry
28. Which of the following tag is used to create a text area in HTML Form?
a) <textarea> </textarea>
b) <text></text>
c) <input type=”text” />
d) <input type=”textarea” />
View Answer
Answer: a
Explanation: The text area tag (<textarea>) is used in a form to declare a text area
element. It allows the user to enter text in multiple rows.
29. To show deleted text, which HTML element is used?
a) <del>
b) <em>
c) <strong>
d) <ins>
View Answer
Answer: a
Explanation: <strong> element shows the importance of text/paragraph between it’s
tags. <em> element indicates emphasis, browser will show the contents of <em>
element in italic. <ins> element shows the content that has been inserted, usually it has
underline. <del> element shows text that has been deleted from, usually it has a line
through the content.
<p>This is <del>not</del> for deletion </p>
<a href="https://www.sanfoundry.com/1000-html-questions-answers/">HTML
MCQ</a>
b)
<a target="https://www.sanfoundry.com/1000-html-questions-answers/" HTML
Quiz />
c)
<a src="https://www.sanfoundry.com/1000-html-questions-answers/">HTML
Test</a>
d)
<a>https://www.sanfoundry.com/1000-html-questions-answers/</a>
View Answer
Answer: a
Explanation: An anchor tag (<a>) and href attribute are used to create a hyperlink in
HTML.
45. Which of the following HTML element is used for canvas graphics?
a) <css>
b) <paint>
c) <canvas>
d) <graphic>
View Answer
Answer: c
Explanation: CSS i.e. Cascading Style Sheet is a scripting language. Canvas graphics
are introduced in HTML5. Element used for canvas graphics is <canvas>. The HTML
canvas element is used to draw graphics, on the fly, via scripting (usually JavaScript).
JS
1. What is JavaScript?
a) JavaScript is a scripting language used to make the website interactive
b) JavaScript is an assembly language used to make the website interactive
c) JavaScript is a compiled language used to make the website interactive
d) None of the mentioned
View Answer
Answer: a
Explanation: JavaScript is a scripting language used along with HTML and CSS to make
the website interactive along. It is used both on the client-side and server-side.
2. Which of the following is correct about JavaScript?
a) JavaScript is an Object-Based language
b) JavaScript is Assembly-language
c) JavaScript is an Object-Oriented language
d) JavaScript is a High-level language
View Answer
Answer: a
Explanation: Although JavaScript is not an OOP (Object-Oriented Programming)
language like Java or PHP, it is object based language. The standard threesome of
polymorphism, encapsulation, and inheritance are the criteria for object orientation, and
JavaScript fails to meet them.
3. Among the given statements, which statement defines closures in JavaScript?
a) JavaScript is a function that is enclosed with references to its inner function scope
b) JavaScript is a function that is enclosed with references to its lexical environment
c) JavaScript is a function that is enclosed with the object to its inner function scope
d) None of the mentioned
View Answer
Answer: b
Explanation: A closure is a function that is enclosed with references to its lexical
environment. A closure allows an inner function to access the scope of an outside
function. Closures are formed every time a function is created in JavaScript, during
function creation time.
4. What will be the output of the following JavaScript code snippet?
<p id="demo"></p>
var txt1 = "Sanfoundry_";
var txt2 = "Javascriptmcq";
document.getElementById("demo").innerHTML = txt1 + txt2;
a) error
b) Sanfoundry_ Javascriptmcq
c) undefined
d) Sanfoundry_Javascriptmcq
View Answer
Answer: d
Explanation: The + operator in javascript acts as a concatenation operator when used
with string. The new string does not have any space between the two added strings.
advertisement
5. What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
var js = 10;
js *= 5;
document.getElementById("demo").innerHTML = js;
</script>
a) 10
b) 50
c) 5
d) Error
View Answer
Answer: b
Explanation: The *= operator in javascript is a shorthand expression for the multiplication
of a particular number. It is a combination of two operators * and = .
6. Arrays in JavaScript are defined by which of the following statements?
a) It is an ordered list of values
b) It is an ordered list of objects
c) It is an ordered list of string
d) It is an ordered list of functions
View Answer
Answer: a
Explanation: An array in JavaScript is an ordered list of values, each value is referred to
as an element, and it is identified by an index. An array can include values of many sorts
and the length of an array dynamically sized.
7. What will be the output of the following JavaScript code?
a) false
b) true
c) compilation error
d) runtime error
View Answer
Answer: b
Explanation: The == in JS convert different types of operands to the same type before
making the comparison. A strict comparison results in true value if the operands are of
the same type and the contents match.
8. What will be the output of the following JavaScript code snippet?
int a=1;
if(a!=null) // JavaScript not equal to Operators
return 1;
else
return 0;
a) 0
b) 1
c) compiler error
d) runtime error
View Answer
Answer: b
Explanation: != is not equal to the operator in Javascript. It gives a value of 1 if the two
values which are compared are not equal and give 0 if the two values are equal.
13. Which of the following object is the main entry point to all client-side JavaScript
features and APIs?
a) Position
b) Window
c) Standard
d) Location
View Answer
Answer: b
Explanation: All client-side JavaScript features and APIs are accessed through the
Window object. It represents a web browser window or frame, and the identifier window
can be used to refer to it.
14. What will be the output of the following JavaScript program?
function sanfoundry(javascript)
{
return (javascript ? “yes” : “no”);
}
bool ans=true;
console.log(sanfoundry(ans));
a) Compilation error
b) Runtime error
c) Yes
d) No
View Answer
Answer: c
Explanation: In javascript, “?” is called the ternary operator which is used for choosing
one choice from the given two choices. It is used instead of if else statement and makes
the code shorter.
15. What will be the output of the following JavaScript code?
a) short
b) 123.56
c) tall
d) 190
View Answer
Answer: a
Explanation: The ternary operator in javascript is used as a comparison operator which
works on three operands. The statement in the above code initializes type variable with
the value short which is returned through the function.
16. Which of the following can be used to call a JavaScript Code Snippet?
a) Function/Method
b) Preprocessor
c) Triggering Event
d) RMI
View Answer
Answer: a
Explanation: A function call to the element on which JavaScript is to be run can be used
to invoke JavaScript code. Other techniques include onclick, onload, and onsubmit,
among others.
17. What will be the output of the following JavaScript function?
<p id="demo"></p>
<script>
function javascript()
{
// javacript abs() method
document.getElementById("demo").innerHTML = Math.abs(-7.25);
}
</script>
a) -7.25
b) 7.25
c) -7
d) 7
View Answer
Answer: b
Explanation: The javacript abs() method returns the absolute value of a number. The
method is found in the math library of Javascript.
18. What will be the output of the following JavaScript code?
a) 1
b) 10
c) 5
d) Error
View Answer
Answer: a
Explanation: Firstly the interpreter checks obj for property b. But it doesn’t find any
property b so it takes the value from outside the object within the JavaScript code
snippet.
19. Which of the following explains correctly what happens when a JavaScript program
is developed on a Unix Machine?
a) will work perfectly well on a Windows Machine
b) will be displayed as JavaScript text on the browser
c) will throw errors and exceptions
d) must be restricted to a Unix Machine only
View Answer
Answer: a
Explanation: Because JS can run on a variety of operating systems, an application
written for UNIX will run just as well on Windows.
20. Which is a more efficient JavaScript code snippet?
Code 1 :
Code 2 :
var num=10;
while(num>=1)
{
document.writeln(num);
num++;
}
a) Code 1
b) Code 2
c) Both Code 1 and Code 2
d) Cannot Compare
View Answer
Answer: a
Explanation: Code 1 would be more efficient JS code. Infact second code will go into
runtime error as the value of num will never reach less than or equal to one.
21. What will be the output of the following JavaScript code?
function printArray(a)
{
var len = a.length, i = 0;
if (len == 0)
console.log("Empty Array");
else
{
// do-while loop in javascript
do
{
console.log(a[i]);
} while (++i < len);
}
}
a) Prints “Empty Array”
b) Prints 0 to the length of the array
c) Prints the numbers in the array in order
d) Prints the numbers in the array in the reverse order
View Answer
Answer: c
Explanation: The do/while statement creates a loop that executes a block of javascript
code once, before checking if the condition is true, then it will repeat the loop as long as
the condition is true. Hence the iterator traverses through the array and print them in
normal order.
22. What happens in the following JavaScript code snippet?
var js = 0;
while (js < 10)
{
console.log(js);
js++;
}
a) An exception is thrown
b) The values of js are logged or stored in a particular location or storage
c) The value of js from 0 to 9 is displayed in the console
d) An error is displayed
View Answer
Answer: c
Explanation: In JavaScript, Console.log is a predefined function that accepts the value
as an argument. At the time of code execution, console.log prints this value in the
argument to the console.
23. What will be the output of the following JavaScript code?
a) 2
b) 5
c) 555
d) error
View Answer
Answer: c
Explanation: for loop in Javascript first initializes the variable and later on checks for the
condition expression and after that execute the line of statements. The value of iterator i
increase until it reaches the value of length.
24. Which of the following scoping type does JavaScript use?
a) Sequential
b) Segmental
c) Lexical
d) Literal
View Answer
Answer: c
Explanation: JavaScript, like most current programming languages, employs lexical
scoping. This means that functions are performed with the variable scope in effect when
they were defined, rather than the variable scope in effect when they are invoked.
25. What is the basic difference between JavaScript and Java?
a) Functions are considered as fields
b) Functions are values, and there is no hard distinction between methods and fields
c) Variables are specific
d) There is no difference
View Answer
Answer: b
Explanation: Java is an object-oriented programming language, while JS is an object-
oriented scripting language. The main difference between JavaScript and Java is that
functions are values, while methods and fields are not clearly defined.
26. What will be the output of the following JavaScript code?
var quiz=[1,2,3];
var js=[6,7,8];
var result=quiz.concat(js);
document.writeln(result);
a) 1, 2, 3, 6, 7, 8
b) 123
c) 1, 2, 3
d) Error
View Answer
Answer: a
Explanation: concat is a predefined function in the array library in Javascript. The concat
function is used to combine the value of two arrays.
i.e.1, 2, 3, 6, 7, 8
27. Why JavaScript Engine is needed?
a) Both Compiling & Interpreting the JavaScript
b) Parsing the javascript
c) Interpreting the JavaScript
d) Compiling the JavaScript
View Answer
Answer: c
Explanation: For the most part, the JS Engine is used to interpret JavaScript. It’s used to
parse javascript and run it on a web page.
28. What will be the function of the following JavaScript program?
int a=0;
for(a;a<5;a++);
console.log(a);
a) 4
b) 5
c) 0
d) error
View Answer
Answer: b
Explanation: The value of a will increase until it equals 5, at which point the cursor will
exit the loop. Because there are no statements in the for loop, the value of a will only
increase. As a result, the result will be five.
30. Which of the following methods/operation does javascript use instead of == and !=?
a) JavaScript uses equalto()
b) JavaScript uses equals() and notequals() instead
c) JavaScript uses bitwise checking
d) JavaScript uses === and !== instead
View Answer
Answer: d
Explanation: The comma operator, bitwise operators, and the ++ and — operators are
not included in the subset. It also forbids the usage of == and!= due to the type
conversion they do, instead requiring the use of === and!==.
31. What will be the result or type of error if p is not defined in the following JavaScript
code snippet?
console.log(p)
a) Not valid
b) Prototype of a function
c) Function javascript
d) A custom constructor
View Answer
Answer: d
Explanation: All object instances have a constructor property that points to the
constructor function that created them. A custom constructor is a constructor which
requires no arguments and is created automatically by the compiler at the time of object
creation if not created by the user.
33. Why event handlers is needed in JS?
a) Allows JavaScript code to alter the behaviour of windows
b) Adds innerHTML page to the code
c) Change the server location
d) Performs handling of exceptions and occurrences
View Answer
Answer: a
Explanation: JS code can change the behavior of windows, documents, and the
elements that make up those documents via event handlers.
34. Which of the following is not a framework?
a) JavaScript .NET
b) JavaScript
c) Cocoa JS
d) jQuery
View Answer
Answer: b
Explanation: jQuery, which is used in web development, is one of the most popular
frameworks. JavaScript is a scripting language, not a framework, in this case.
35. Which of the following is the property that is triggered in response to JS errors?
a) onclick
b) onerror
c) onmessage
d) onexception
View Answer
Answer: b
Explanation: The Window object’s onerror property acts as an event handler, and it is
triggered when JavaScript problems occur. However, because it is called with various
arguments, it isn’t a genuine event handler.
36. What will be the output of the following JavaScript code?
function compare()
{
int sanfoundry=1;
char javascript=1;
if(sanfoundry.tostring()===javascript)
return true;
else
return false;
}
a) runtime error
b) logical error
c) true
d) false
View Answer
Answer: c
Explanation: The .tostring() function can be used to convert a non-string (integer) to a
string. Only if the operands are of the same type and the contents match is a rigorous
comparison possible. As a result, the following code line will produce true output.
37. What will be the firstname and surname of the following JavaScript program?
var book = {
"main title": "JavaScript",
'sub-title': "The Definitive Guide",
"for": "all audiences",
author: {
firstname: "David",
surname: "Flanagan"
}
};
a) objects
b) property names
c) properties
d) property values
View Answer
Answer: b
Explanation: An item is contained within another object in the code sample above. The
property names are firstname and surname. The value of that property is an object in
and of itself.
38. Which of the following is not an error in JavaScript?
a) Missing of Bracket
b) Division by zero
c) Syntax error
d) Missing of semicolons
View Answer
Answer: b
Explanation: In JavaScript, division by zero does not result in an error; it just returns
infinity or negative infinity. However, because zero divided by zero has no well-defined
value, the result of this operation is the unusual not-a-number value, which is written as
NaN.
39. Consider the following JavaScript statement containing regular expressions and
check if the pattern matches.
CSS
1. What is CSS?
a) CSS is a style sheet language
b) CSS is designed to separate the presentation and content, including layout, colors,
and fonts
c) CSS is the language used to style the HTML documents
d) All of the mentioned
View Answer
Answer: d
Explanation: CSS is a style sheet language that stands for Cascading Style Sheet and is
used to style HTML documents. CSS is mainly designed to separate the presentation
and content, including layout, colors, and fonts.
2. Which of the following tag is used to embed css in html page?
a) <css>
b) <!DOCTYPE html>
c) <script>
d) <style>
View Answer
Answer: d
Explanation: <style> </style> tag is used to embed CSS in HTML page, while <script>
</script> is used to embed JS in HTML. <!DOCTYPE html> is HTML5 declaration.
3. Which of the following CSS selectors are used to specify a group of elements?
a) tag
b) id
c) class
d) both class and tag
View Answer
Answer: c
Explanation: Class selectors are used to specify a group of elements. Id selector
specifies a particular unique element.
4. Which of the following has introduced text, list, box, margin, border, color, and
background properties?
a) HTML
b) PHP
c) CSS
d) Ajax
View Answer
Answer: c
Explanation: CSS is a style sheet language that stands for Cascading Style Sheet. CSS
has introduced text, list, box, margin, border, color, and background properties.
5. Which of the following CSS framework is used to create a responsive design?
a) django
b) rails
c) larawell
d) bootstrap
View Answer
Answer: d
Explanation: Bootstrap is a free and open-source collection of tools for creating websites
and web applications. It contains HTML- and CSS-based design templates for
typography, forms, buttons, navigation and other interface components, as well as
optional JavaScript extensions. It aims to ease the development of dynamic websites
and web applications.
advertisement
6. Which of the following CSS selector is used to specify a rule to bind a particular
unique element?
a) tag
b) id
c) class
d) both class and tag
View Answer
Answer: b
Explanation: For binding a particular unique element, id selectors are used. While for a
group of elements, class selector can be used.
7. Which of the following type of HTML tag is used to define an internal style sheet?
a) <script>
b) <link>
c) <class>
d) <style>
View Answer
Answer: d
Explanation: <style> tag is used to define an internal style sheet in HTML document.
8. Which of the following CSS property is used to make the text bold?
a) text-decoration: bold
b) font-weight: bold
c) font-style: bold
d) text-align: bold
View Answer
Answer: b
Explanation: The font-weight property is used for setting the thickness and boldness of
the font. It is used to define the weight of the text. The available weight depends on the
font-family, which is used by the browser.
9. What will be the output of following CSS code snippet?
h1 {color: "green";}
a) nothings happen
b) error occurs
c) heading becomes dark-green
d) heading becomes green
View Answer
Answer: a
Explanation: Output of the above code snippet won’t happen as the declaration syntax is
wrong. The correct declaration is : h1 { color: green; } which will yield an output. In CSS,
we don’t write the value in double quotes.
10. Which of the following CSS style property is used to specify an italic text?
a) style
b) font
c) font-style
d) @font-face
View Answer
Answer: c
Explanation: font-style property is used to specify an italic text. font-style property has
three values (normal, italic & oblique).
11. What will be the output of following CSS code snippet?
20. Which of the following is not the property of the CSS box model?
a) margin
b) color
c) width
d) height
View Answer
Answer: b
Explanation: CSS box model include height, width, padding, margin and border. All text-
fields have complete support for every property related to CSS box model. Browser
relies on system default styles when displaying these widgets.
21. Which of the following CSS property sets what kind of line decorations are added to
an element, such as underlines, overlines, etc?
a) text-decoration
b) text-style
c) text-decoration-line
d) text-line
View Answer
Answer: c
Explanation: The text-decoration-line property defines the type of line decorations that
are added to an element, such as underlines, overlines, etc.
22. Which of the following CSS property specifies the look and design of an outline?
a) outline-style
b) outline-format
c) outline-font
d) none of the mentioned
View Answer
Answer: a
Explanation: The outline-style CSS property is used to set the style of the outline of an
element. An outline is a line that is drawn around elements, outside the border edge, to
make the element stand out.
23. What will be the output of the following CSS code snippet?
span {
border: 1px solid red;
outline: green dotted thick;
}
a) All span elements will have a green thick border and a red outline
b) All span elements will have a red border and a green dotted outline
c) All span elements will have a outer green dotted border and an inner red border
d) All span elements will have an outer red border and inner green dotted border
View Answer
Answer: c
Explanation: The border property creates the inner border, while the outline sets the
outer border.
24. Which of the following CSS property sets the shadow for a box element?
a) set-shadow
b) box-shadow
c) shadow
d) canvas-shadow
View Answer
Answer: b
Explanation: box-shadow property sets the shadow for a box element.
CSS Syntax:
box-shadow: none | inherit
25. Which of the following CSS property is used to set the color of the text?
a) text-decoration
b) pallet
c) colour
d) color
View Answer
Answer: d
Explanation: The color property is used to set the color of the text. In CSS, colors can
also be specified using RGB values, RGBA values, HSL values, HEX values, etc.
26. Which of the following CSS Property controls how an element is positioned?
a) static
b) position
c) fix
d) set
View Answer
Answer: b
Explanation: Position property controls how an element is positioned. When set to
absolute or fixed, the element is removed completely from the normal flow of the
document. When set to relative, the element is moved relative to its position in the
normal flow, but a space is left where it would normally have been. The default value,
static, means the element remains in the normal flow and is not positioned.
27. Which of the following CSS selector selects the elements that are checked?
a) :checked
b) E ~ F
c) ::after
d) none of the mentioned
View Answer
Answer: a
Explanation: :checked selector selects the elements that are checked.
Example: :checked {color: blue;}
28. Which of the following is an appropriate value for the overflow element?
a) scroll
b) hidden
c) auto
d) all of the mentioned
View Answer
Answer: d
Explanation: Overflow of a div or a container can have the following values:
visible|hidden|scroll|auto|initial|inherit
29. Which of the following CSS property is used to specify table borders in CSS?
a) table:border
b) table
c) border
d) none of the mentioned
View Answer
Answer: c
Explanation: In CSS, border property is used to specify table borders.
Example:
table{border: 7px solid black;}
30. Which of the following property is used to align the text in a table?
a) text-align
b) align
c) text
d) none of the mentioned
View Answer
Answer: a
Explanation: In CSS, text-align property is used to align the text in a table.
Example:
table{text-align: left;}
31. Which of the following CSS Property sets the stacking order of positioned elements?
a) y-index
b) z-index
c) x-index
d) all of the mentioned
View Answer
Answer: b
Explanation: z-index property sets the stacking order of positioned elements.
Syntax:
z-index: auto|number|initial|inherit;
div {
border-width:5px;
border-style:dotted solid double dashed;
}
a) Box having dotted bottom outline, solid right outline, double top outline and dashed
left outline
b) Box having dotted bottom outline, solid left outline, double top outline and dashed left
outline
c) Box having dotted top outline, solid right outline, double bottom outline and dashed
left outline
d) Box having dotted top outline, solid left outline, double bottom outline and dashed
right outline
View Answer
Answer: c
Explanation: The shorthand run in clockwise direction.
33. Which of the following property allows a marquee to be used in the case of a text-
overflow?
a) overflow-marquee
b) overflow-style
c) overflow-text
d) none of the mentioned
View Answer
Answer: b
Explanation: overflow-style is a CSS property that allows a marquee to be used in the
case of a text-overflow.
Syntax:
overflow-style: auto | marquee-block
34. Which of the following CSS property defines the space between cells in a table?
a) border-spacing
b) border-style
c) border
d) none of the mentioned
View Answer
Answer: a
Explanation: border-spacing property defines the space between cells in a table.
Syntax:
border-spacing: non-negative length(s) | inherit
35. Which of the following CSS3 property can be used to allow line breaks within words?
a) line-break
b) line-wrap
c) word-wrap
d) word-break
View Answer
Answer: d
Explanation: word-break property can be used to allow line breaks within the words.
Syntax:
word-break: break-all | keep-all | normal
PHP
1. What is PHP?
a) PHP is an open-source programming language
b) PHP is used to develop dynamic and interactive websites
c) PHP is a server-side scripting language
d) All of the mentioned
View Answer
Answer: d
Explanation: PHP is an open-source server-side scripting language that is used to build
dynamic and interactive web pages or web applications.
2. Who is the father of PHP?
a) Drek Kolkevi
b) Rasmus Lerdorf
c) Willam Makepiece
d) List Barely
View Answer
Answer: b
Explanation: PHP was originally created by Rasmus Lerdorf in 1994.
3. What does PHP stand for?
a) PHP stands for Preprocessor Home Page
b) PHP stands for Pretext Hypertext Processor
c) PHP stands for Hypertext Preprocessor
d) PHP stands for Personal Hyper Processor
View Answer
Answer: c
Explanation: PHP previously stood for Personal Home Page now stands for “Hypertext
Preprocessor”.
4. Which of the following is the correct syntax to write a PHP code?
a) <?php ?>
b) < php >
c) < ? php ?>
d) <? ?>
View Answer
Answer: d
Explanation: Every section of PHP code starts and ends by turning on and off PHP tags
to let the server know that it needs to execute the PHP in between them.
5. Which of the following is the correct way to add a comment in PHP code?
a) #
b) //
c) /* */
d) All of the mentioned
View Answer
Answer: d
Explanation: In PHP, /* */ can also be used to comment just a single line although it is
used for paragraphs. // and # are used only for single-line comments.
advertisement
6. Which of the following is the default file extension of PHP files?
a) .php
b) .ph
c) .xml
d) .html
View Answer
Answer: a
Explanation: To run a PHP file on the server, it should be saved as AnyName.php
7. How to define a function in PHP?
a) functionName(parameters) {function body}
b) function {function body}
c) function functionName(parameters) {function body}
d) data type functionName(parameters) {function body}
View Answer
Answer: c
Explanation: PHP allows us to create our own user-defined functions. Any name ending
with an open and closed parenthesis is a function. The keyword function is always used
to begin a function.
8. What will be the output of the following PHP code?
<?php
$x = 10;
$y = 20;
if ($x > $y && 1||1)
print "1000 PHP MCQ" ;
else
print "Welcome to Sanfoundry";
?>
a) no output
b) Welcome to Sanfoundry
c) 1000 PHP MCQ
d) error
View Answer
Answer: c
Explanation: Expression evaluates to true.
Output:
1000 PHP MCQ
9. Which is the right way of declaring a variable in PHP?
a) $3hello
b) $_hello
c) $this
d) $5_Hello
View Answer
Answer: b
Explanation: A variable in PHP can not start with a number, also $this is mainly used to
refer properties of a class so we can’t use $this as a user defined variable name.
10. What will be the output of the following PHP program?
<?php
$fruits = array ("apple", "orange", array ("pear", "mango"),"banana");
echo (count($fruits, 1));
?>
a) 6
b) 5
c) 4
d) 3
View Answer
Answer: a
Explanation: function count() will return the number of elements in an array. The
parameter 1 counts the array recursively i.e it will count all the elements of
multidimensional arrays.
11. What will be the output of the following PHP program?
<?php
function multi($num)
{
if ($num == 3)
echo "I Wonder";
if ($num == 7)
echo "Which One";
if ($num == 8)
echo "Is The";
if ($num == 19)
echo "Correct Answer";
}
$can = stripos("I love php, I love php too!","PHP");
multi($can);
?>
a) Correct Answer
b) Is The
c) I Wonder
d) Which One
View Answer
Answer: d
Explanation: The stripos() function finds the position of the first occurrence of a string
inside another string. In this case it returns 7.
12. Which of the following PHP functions can be used for generating unique ids?
a) md5()
b) uniqueid()
c) mdid()
d) id()
View Answer
Answer: b
Explanation: The function uniqueid() is used to generate a unique ID based on the
microtime (current time in microseconds). The ID generated from the function uniqueid()
is not optimal, as it is based on the system time. To generate an ID which is extremely
difficult to predict we can use the md5() function.
13. In the following PHP program, what is/are the properties?
<?php
class Example
{
public $name;
function Sample()
{
echo "Learn PHP @ Sanfoundry";
}
}
?>
a) function sample()
b) echo “This is an example”;
c) public $name;
d) class Example
View Answer
14. What will be the output of the following PHP code?
<?php
define("GREETING", "PHP is a scripting language");
echo $GREETING;
?>
a) $GREETING
b) no output
c) PHP is a scripting language
d) GREETING
View Answer
15. A function in PHP which starts with __ (double underscore) is known as __________
a) Default Function
b) User Defined Function
c) Inbuilt Function
d) Magic Function
View Answer
16. How many functions does PHP offer for searching and modifying strings using Perl-
compatible regular expressions.
a) 10
b) 7
c) 8
d) 9
View Answer
17. Which of the following web servers are required to run the PHP script?
a) Apache and PHP
b) IIS
c) XAMPP
d) Any of the mentioned
View Answer
18. What will be the output of the following PHP code snippet?
<?php
$url = "phpmcq@sanfoundry.com";
echo ltrim(strstr($url, "@"),"@");
?>
a) phpmcq@sanfoundry.com
b) php@sanfoundry.com
c) phpmcq@
d) sanfoundry.com
View Answer
19. Which of the following PHP functions can be used to get the current memory usage?
a) memory_get_usage()
b) memory_get_peak_usage()
c) get_peak_usage()
d) get_usage()
View Answer
Answer: a
Explanation: memory_get_usage() returns the amount of memory, in bytes, that’s
currently being allocated to the PHP script. We can set the parameter ‘real_usage’ to
TRUE to get total memory allocated from system, including unused pages. If it is not set
or FALSE then only the used memory is reported. To get the highest amount of memory
used at any point, we can use the memory_get_peak_usage() function.
20. Which one of the following PHP function is used to determine a file’s last access
time?
a) filetime()
b) fileatime()
c) fileltime()
d) filectime()
View Answer
Answer: b
Explanation: The fileatime() function returns a file’s last access time in Unix timestamp
format or FALSE on error.
21. What will be the output of the following PHP code?
<?php
$x = 5;
$y = 10;
function fun()
{
$y = $GLOBALS['x'] + $GLOBALS['y'];
}
fun();
echo $y;
?>
a) 5
b) 10
c) 15
d) Error
View Answer
Answer: b
Explanation: The value of global variable y does not change therefore it’ll print 10;
22. PHP recognizes constructors by the name _________
a) function __construct()
b) function _construct()
c) classname()
d) _construct()
View Answer
Answer: a
Explanation: PHP recognizes constructors by double underscore followed by the
construct keyword. Its syntax is function __construct ([ argument1, argument2,…..])
{ Class Initialization code }.
23. The developers of PHP deprecated the safe mode feature as of which PHP version?
a) PHP 5.3.1
b) PHP 5.3.0
c) PHP 5.1.0
d) PHP 5.2.0
View Answer
Answer: b
Explanation: This happened because safe mode often creates many problems as it
resolves, largely due to the need for enterprise applications to use many of the features
safe mode disables.
24. What will be the value of the variable $input in the following PHP program?
<?php
$input = "PHP<td>stands for</td>Hypertext<i>Preprocessor</i>!";
$input = strip_tags($input,"<i></i>");
echo $input;
?>
i) $_SERVER['PHP_AUTH_USER'].
ii) $_SERVER['PHP_AUTH_USERS'].
iii) $_SERVER['PHP_AUTH_PU'].
iv) $_SERVER['PHP_AUTH_PW'].
<?php
$a = 100;
if ($a > 10)
printf("PHP Quiz");
else if ($a > 20)
printf("PHP MCQ");
else if($a > 30)
printf("PHP Program");
?>
a)
PHP Quiz
PHP MCQ
PHP Program
b) PHP Quiz
c) No output
d) PHP MCQ
View Answer
Answer: b
Explanation: In if else if one condition is satisfied then no other condition is checked.
28. Which of the looping statements is/are supported by PHP?
i) for loop
a) Only iv)
b) i) and ii)
c) i), ii) and iii)
d) i), ii), iii) and iv)
View Answer
Answer: d
Explanation: All are supported looping statements in PHP as they can repeat the same
block of code a given number of times, or until a certain condition is met.
29. Which PHP statement will give output as $x on the screen?
a) echo “\$x”;
b) echo “$$x”;
c) echo “/$x”;
d) echo “$x;”;
View Answer
Answer: a
Explanation: A backslash is used so that the dollar sign is treated as a normal string
character rather than prompt PHP to treat $x as a variable. The backslash used in this
manner is known as the escape character.
30. Which version of PHP introduced the advanced concepts of OOP?
a) PHP 6
b) PHP 4
c) PHP 5
d) PHP 5.3
View Answer
Answer: c
Explanation: Advanced concepts of OOP were introduced in PHP version 5.
31. What will be the output of the following PHP code?
<?php
$x = 4;
$y = 3
$z = 1;
$z = $z + $x + $y;
echo "$z";
?>
a) 15
b) 8
c) 1
d) $z
View Answer
Answer: b
Explanation: Normal addition of variables x, y and z occurs and result of 8 will be
displayed.
32. What will be the output of the following PHP program?
<?php
$a = "$winner";
$b = "/$looser";
echo $a,$b;
?>
a) /
b) $looser
c) /$looser
d) $winner/$looser
View Answer
Answer: a
Explanation: Since variables $winner and $looser is not defined we only see / as output.
33. Which one of the following is the default PHP session name?
a) PHPSESSIONID
b) PHPIDSESS
c) PHPSESSID
d) PHPSESID
View Answer
Answer: c
Explanation: PHPSESSID is the default PHP session name. You can change this name
by using the session.name directive.
34. What will be the output of the following PHP program?
<?php
$mcq = 1;
switch(print $mcq)
{
case 2:
print "HTML";
break;
case 1:
print "CSS";
break;
default:
print "JavaScript";
}
?>
a) error
b) 1HTML
c) 1JavaScript
d) 1CSS
View Answer
Answer: d
Explanation: Print returns 1, thus it gives case 1.
35. What will be the output of the following PHP program?
<?php
define("VAR_NAME","test");
${VAR_NAME} = "value";
echo VAR_NAME;
echo ${VAR_NAME};
?>
a) testtest
b) testvalue
c) error, constant value cannot be changed
d) test
View Answer
Answer: b
Explanation: ${VAR_NAME} creates a new variable that is not same as VAR_NAME.
36. Which PHP function displays the web page’s most recent modification date?
a) getlastmod()
b) get_last_mod()
c) lastmod()
d) last_mod()
View Answer
Answer: a
Explanation: The function getlastmod() gets the time of the last modification of the main
script of execution. It returns the value of the page’s last modified header or FALSE in
the case of an error.
37. What will be the output of the following PHP program?
<?php
$i = 5;
while (--$i > 0 && ++$i)
{
print $i;
}
?>
a) 555555555…infinitely
b) 54321
c) error
d) 5
View Answer
Answer: a
Explanation: As it is && operator it is being incremented and decremented continuously
in PHP.
38. What will be the output of the following PHP code?
<?php
function constant()
{
define("GREETING", "Welcome to Sanfoundry",true);
echo greeting;
}
?>
a) GREETING
b) Welcome to Sanfoundry
c) ERROR
d) greeting
View Answer
Answer: b
Explanation: By default, constants are case sensitive in php. But the third parameter in
define(), if set to true, makes constants case insensitive.
39. Which variable is used to collect form data sent with both the GET and POST
methods?
a) $_BOTH
b) $REQUEST
c) $_REQUEST
d) $BOTH
View Answer
Answer: c
Explanation: In PHP the global variable $_REQUEST is used to collect data after
submitting an HTML form.
40. What will be the output of the following PHP program?
<?php
$php = array("Array", "Function", "Strings", "File");
echo pos($php);
?>
a) Function
b) File
c) Strings
d) Array
View Answer
Answer: d
Explanation: The pos() function returns the value of the current element in an array, and
since no operation has been done, the current element is the first element.
41. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
a) 1
b) 5
c) 12
d) Error
View Answer
Answer: b
Explanation: ?: is known as ternary operator. If condition is true then the part just after
the ? is executed else the part after