Professional Documents
Culture Documents
Show Answer
Q.
HTML uses
A.User defined tagsB.Pre-specified tags
C.Fixed tags defined by the languageD.Tags only for linking
Answer : Fixed tags defined by the language [Option : C]
Show Answer
Q.
The year in which HTML was first proposed _______.
A.1990B.1980
C.2000D.1995
Answer : 1990 [Option : A]
Show Answer
Q.
Fundamental HTML Block is known as ___________.
A.HTML BodyB.HTML Tag
C.HTML AttributeD.HTML Element
Answer : HTML Tag [Option : B]
Show Answer
Q.
Apart from <b> tag, what other tag makes text bold ?
A.<fat>B.<strong>
C.<black>D.<emp>
Answer : <strong> [Option : B]
Q.
What is the full form of HTML?
A.HyperText Markup LanguageB.Hyper Teach Markup Language
C.Hyper Tech Markup LanguageD.None of these
Answer : HyperText Markup Language [Option : A]
Show Answer
Q.
Who is Known as the father of World Wide Web (WWW)?
A.Robert CailliauB.Tim Thompson
C.Charles DarwinD.Tim Berners-Lee
Answer : Tim Berners-Lee [Option : D]
Show Answer
Q.
What should be the first tag in any HTML document?
A.<head>B.<title>
C.<html>D.<document>
Answer : <html> [Option : C]
Show Answer
Q.
How can you make a bulleted list with numbers?
A.<dl>B.<ol>
C.<list>D.<ul>
Answer : <ol> [Option : B]
Show Answer
Q.
What tag is used to display a picture in a HTML page?
A.pictureB.image
C.imgD.src
Answer : img [Option : C]
Show Answer
Q.
Which of the following is not a browser ?
A.Microsofts BingB.Netscape Navigator
C.Mozilla FirefoxD.Opera
Answer : Microsofts Bing [Option : A]
Show Answer
Q.
Which HTML tag produces the biggest heading?
A.<h7>B.<h9>
C.<h4>D.<h1>
Answer : <h1> [Option : D]
Show Answer
Q.
HTML tags are surrounded by which type of brackets.
A.CurlyB.Round
C.SquartD.Angle
Answer : Angle [Option : D]
Show Answer
Q.
Tags and texts that are not directly displayed on the page are written in _____ section.
A.<head>B.<title>
C.<body>D.<html>
Answer : <head> [Option : A]
1.) What is the preferred way for adding a background color in HTML?
a.) <body background="yellow">
b.) <background>yellow</background>
c.) < body style="background-color:yellow">
d.) <background color="yellow">text<background>
View Answer / Hide Answer
ANSWER: b.) If
4.) The _______ method of an Array object adds and/or removes elements from an array.
a.) Reverse
b.) Shift
c.) Slice
d.) Splice
View Answer / Hide Answer
5.) To set up the window to capture all Click events, we use which of the following
statement?
a.) window.captureEvents(Event.CLICK);
b.) window.handleEvents (Event.CLICK);
c.) window.routeEvents(Event.CLICK );
d.) window.raiseEvents(Event.CLICK );
View Answer / Hide Answer
7.) Choose the correct HTML tag for the largest heading
a.) <h6>
b.) <heading>
c.) <head>
d.) <h1>
View Answer / Hide Answer
8.) What is the correct HTML tag for inserting a line break?
a.) <br />
b.) <break />
c.) <lb />
d.) <nbsp>
View Answer / Hide Answer
ANSWER: c.) margin-left: 1.) To match the root node in XMLT transform the syntax will be.
a.) <xsl:template match="Document">
b.) <xsl:template match="Root">
c.) <xsl:template match="RootNode">
d.) <xsl:template match="/">
View Answer / Hide Answer
2.) To match the specific XML elements child like of parent element is the syntax will be.
a.) <xsl:template match="PLANET_NAME">
b.) <xsl:template match="PLANET/NAME">
c.) <xsl:template match="/NAME">
d.) <xsl:template match="//">
View Answer / Hide Answer
4.) Which CSS property can provide to add an effect when changing from one style to
another,without using Flash animations or javascript?
a.) Associations
b.) Transitions
c.) Transistor
d.) None of the above
View Answer / Hide Answer
8.) To enable data tainting, the end user sets the _________ environment variable.
a.) ENABLE_TAINT
b.) MS_ENABLE_TAINT
c.) NS_ENABLE_TAINT
d.) ENABLE_TAINT_NS
View Answer / Hide Answer
9.) In JavaScript, _________ is an object of the target language data type that encloses an
object of the source language.
a.) a wrapper
b.) a link
c.) a cursor
d.) a form
View Answer / Hide Answer
10) When a JavaScript object is sent to Java, the runtime engine creates a Java wrapper of
type
a.) ScriptObject
b.) JSObject
c.) JavaObject
d.) Jobject
View Answer / Hide Answer
ANSWER: b.) JSObject 1.) iframe in HTML is used to display a web page within a web
page.
a.) TRUE
b.) FALSE
View Answer / Hide Answer
5.) HTML Event Attributes onload fires just before the page is finishing loading.
a.) TRUE
b.) FALSE
View Answer / Hide Answer
ANSWER: a.) To store information usually relevant to browsers and search engines
1.) The trick to getting a ball to bounce around a Web page is to:
a.) Add AnimationBounce layers
b.) Add keyframes to the timeline
c.) Add Bounce parameters to the Object properties
d.) Dreamweaver does not support animation... use Flash instead
View Answer / Hide Answer
ANSWER: a.) 15
4.) When trying to access a URL, the following message is displayed on the browser:
ANSWER: d.) The requested HTML file or CGI script has insufficient permission
5.) Dreamweaver users work in the Document Window using one of how many views?
a.) 3
b.) 5
c.) 2
d.) 8
View Answer / Hide Answer
ANSWER: a.) 3
6.) The general definition of a(n) ____ is a set of linked documents with shared attributes,
such as related topics, a similar design, or a shared purpose.
a.) index
b.) website
c.) Internet
d.) Homepage
View Answer / Hide Answer
7.) What type of technology allows you to verbally speak with someone over the Internet?
a.) Wiki
b.) Social network
c.) Ephone
d.) VoIP
View Answer / Hide Answer
8.) Dreamweaver's ____ feature allows users to select colors and make perfect color
matches.
a.) Color Cube
b.) Palattes
c.) HTML view
d.) Eye dropper
View Answer / Hide Answer
10.) _________ view is a hand-coding environment for writing and editing code
a.) Design
b.) Split
c.) Code
View Answer / Hide Answer
3.) What is the correct HTML for making a text input field?
a.) <input type="textfield" />
b.) <textinput type="text" />
c.) <textfield>
d.) <input type="text" />
View Answer / Hide Answer
10.) The TFOOT section of a table must appear before the TBODY section.
a.) FALSE
b.) TRUE
View Answer / Hide Answer
Question 2 : To make your website mobile friendly, you can make your website
a) Responsive
b) Reactive
c) Fast Loading
d) Light
Answer : a (Responsive)
c) It is a Software
d) It is a database
c) It is a Software
d) It is a database
a) Power Point
b) Excel
c) Dream Weaver
d) ERP
a) WordPress
b) Drupal
c) Magneto
d) SAP
Answer : d (SAP)
d) Though more expensive than shared hosting, Dedicated hosting is more secure
a) Hostgator
b) Blue Host
c) WPX Hosting
d) Facebook
Answer : d (Facebook)
a) The web designer shouldn’t just be concerned about the looks but also about user
interface
c) a and b
Answer : c ( a & b)
d) a & b
Answer : d (a & b)
(A) PASCAL
(B) C
(C) HTML
(D) BASIC
Ans: C
HTML
Question: 2
What is the abbreviation of HTTP?
(D) None
Ans: B
Question: 3
(A) Comments
(B) Tags
Ans: D
HTML element
Question: 4
Ans: D
<HTML> tag
Question: 5
GIF is the abbreviation for ___
Ans: A
(A) <BIG>tag
(B) <SMALL>tag
(C) <MARQUEE>tag
Ans: D
<BIG>and<Small> tags
Question: 7
(D) WWW
Ans: C
WWW consortium
Question: 8
(A) <FONT>
(B) <HR>
(C) <HI>
(D) <IMG>
Ans: D
<IMG>
Question: 9
The ____ passes the information given by the user to a specified program.
(A) User
(B) Programmer
(D) Browser
Ans: C
Web server
Question: 10
____ is used to store the data within the documents on the server.
(A) XML
(B) HTML
(C) DHTML
(D) CGI
Ans: A
XML
CGI stands for ___
Ans: B
Question: 2
(A) Form
(B) Field
(C) Table
(D) Frame
Ans: A
Form
Question: 3
(A) Functions
(B) Events
(C) Files
(D) Lists
Ans: D
Lists
Question: 4
(B) .JPG
(C) .JPEG
Ans: A
Question: 5
(A) Two
(B) Three
(C) Five
(D) Six
Ans: D
Six
Which is an attribute of Meta tag?
(A) Name
(B) Content
(D) None
Ans: B
Content
Question: 7
Which tag is used to provide additional information about the page that is not visible in the
browser?
Ans: B
Meta tag
Question: 8
Which character is used after the opening angular bracket to represent the closing tag?
(A) /
(B)
(C) |
(D) %
Ans: A
Question: 9
(B) Comments
Ans: B
Comments
Question: 10
Ans: C
(D) None
Ans: B
Heading section
Question: 2
(D) None
Ans: A
Question: 3
(A) Size
(B) ALT
(C) ALIGN
(D) SRC
Ans: B
ALT
Question: 4
Ans: D
Question: 5
(B) Italics
(D) Bold
Ans: C
Ans: D
Which tag is used to change the default characteristics of a particular tag in the entire web
document wherever that tag is used?
Ans: B
Style tag
Question: 8
(A) SIZE
(B) BG COLOR
(C) DIRECTION
Ans: D
Question: 9
(A) CELLPADDING
(B) WIDTH
(C) CELLSPACING
(D) BORDER
Ans: B
WIDTH
Question: 10
Which one of the following indicates how light or dark a color appears on the web page?
(A) Value
(B) shade
(C) Hue
(D) Tint
Ans: A
Value The communication protocol used by the Internet to transfer hypertext documents is
___
Ans: B
Question: 2
The instructions indicated to the browser to display a document are called ___
(A) Codes
(B) Tags
(C) Programs
(D) Statements
Ans: B
Tags
Question: 3
The primary colors are ____
Ans: C
Question: 4
(A) 64
(B) 156
(C) 256
(D) 264
Ans: C
256
Question: 5
Transferring your HTML code from one machine to server is known as ___
(A) Indexing
(B) Hosting
(C) Serving
(D) Sorting
Ans: B
Hosting
The _____ attribute is used to specify the value to be stored in the variable if an option is
selected.
(A) SIZE
(B) VALUE
(C) CHECKED
(D) TYPE
Ans: B
VALUE
Question: 7
Ans: C
DHTML, XML
Question: 8
(A) Structure
(B) Tag
Ans: D
Body section
Question: 9
Which of the following enables the computers around the world to be connected together?
(A) Assembler
(B) Compiler
(D) Internet
Ans: D
Internet
Question: 10
(B) Notepad
Ans: C
(A) Standards
(B) Protocol
(C) Syntax
(D) Language
Ans: B
Protocol
Question: 2
Which term is used to refer to the computers that are used for storing web pages as files?
(A) Internet
Ans: B
Web clients
Question: 3
Ans: B
Question: 4
Ans: C
Question: 5
Interactive documents that can be created using a feature of HTML are called ____
(A) Tables
(B) Forms
(C) Files
(D) Frames
Ans: B
Forms
_____ are used to allow the user to select one of the options displayed.
Ans: A
Radio buttons
Question: 7
_____ is used to separate the attributes in the selected segment of a style tag.
(A) :
(B) ;
(C) ,
(D) *
Ans: B
Question: 8
(A) Size
(B) SRC
(C) Color
(D) Font
Ans: B
SRC
Question: 9
(A) FONT
(B) COLOR
(C) TYPE
(D) SIZE
Ans: C
TYPE
Question: 10
(A) FFOOFF
(B) FFFFFF
(C) FFOOOO
(D) FFFFOO
Ans: C
FFOOOO
What is the abbreviation of WWW?
Ans: D
World Wide Web
Question: 2
Which of the following attributes specifies the name of the image file?
(A) Font
(B) SRC
(C) Color
(D) Size
Ans: B
SRC
Question: 3
(A) Web
(C) Clipart
(D) Toolbar
Ans: C
Clipart
Question: 4
Software applications used for creating web pages and web sites are called as ___
Ans: B
Web page editors
Question: 5
(A) BGCOLOR
(B) Link
(C) VLINK
(D) TEXT
Ans: B
Link _____ attribute can be added to make one of the options as the default option.
(A) SIZE
(B) CHECKED
(C) TYPE
(D) VALUE
Ans: B
CHECKED
Question: 7
Which of the following is the content of a document that includes text, pictures and links to
other related documents?
(C) Computer
(D) Software
Ans: B
Hyper Text
Question: 8
(A) 2
(B) 3
(C) 4
(D) 6
Ans: A
Question: 9
_____ provides facilities required to link several related documents already stored on
computers.
(A) HTML
(B) Computer
(C) Software
(D) Internet
Ans: A
HTML
Question: 10
(A) HTML
(B) Ms Paint
(C) Notepad
(D) FrontPage
Ans: D
FrontPage
Who send the requisition for web pages to the web servers?
(A) Node
(B) System
Ans: C
Web clients
Question: 2
Which tag is used to identify the author’s name of the web document?
Ans: B
Meta tag
Question: 3
(A) Link
(B) ALINK
(C) VLINK
Ans: D
Question: 4
The ___ option allows the user to specify a location on the web.
(A) Format
(C) Location
(D) Insert
Ans: B
From location
Question: 5
(A) Notepad
(B) SGML
(C) Gopher
(D) Computer
Ans: C
Gopher
Which indicates the beginning of an effect?
(C) Tag
Ans: A
Start tag
Question: 7
Which option on the menu can be used to insert rows and columns?
(A) Insert
(B) Tool
(C) Table
(D) Format
Ans: C
Table
Question: 8
(A) DHTML
(B) XML
(C) HTML
(D) CGI
Ans: A
DHTML
Question: 9
Ans: A
Question: 10
(A) HTML
(B) FrontPage
(C) Notepad
(D) MS Paint
Ans: C
Notepad
1. State whether the given statement is true or false. !DOCTYPE is case sensitive”.
a) True
b) False
View Answer
Answer: b
3. Which of the following XHTML doctype declaration contains all HTML elements and
attributes, including presentational and deprecated elements (like font) but not framesets?
a) !DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”
b) !DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”
c) !DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”
d) <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
View Answer
Answer: b
5. What indicates the content in file is HTML when delivered on the network.
a) The extension of the file “.html”
b) The “content-type” header
c) Both “.html” extension and “content-type” header
d) The “content_type” header
View Answer
Answer: b
Explanation: Content-type: header indicates the content in the file is HTML and we can see
file content through it when delivered on the network. “.html” is the file extension for HTML.
6. State whether the given statement is true or false. “We can intermix XHTML and HTML
4.01 documents”
a) True
b) False
View Answer
Answer: b
Explanation: HTML is not in XML format. You have to make the changes necessary to make
the document proper XML before you can get it accepted as XML.
10. Choose the correct HTML for width attribute and its value.
a) width=80
b) width=”80″
c) WIDTH=”80″
d) WIDTH=80
View Answer
Answer: b
i. <B>Go boldly</B>
ii. <B>Go boldly</b>
iii. <b>Go boldly</B>
iv. <b>Go boldly</b>
a) iv
b) i
c) i, ii, iii, and iv
d) both iv and i
View Answer
Answer: c
Explanation: Traditional HTML is case insensitive and thus we can write tag/element name
either in lowercase or uppercase or both which will be ignored by browser by default.
advertisement
<strong>T e s t o f s p a c e s</strong><br>
<strong>T e s t o f s p a c e s </strong><br>
a) T e s t o f s p a c e s
Testofspaces
b) Testofspaces
Testofspaces
c) T e s t o f s p a c e s
T e s t o f s p a c e s
d) T e s t o f s p a c e s T e s t o f s p a c e s
View Answer
Answer: c
Explanation: The strong tag is used to highlight the importance of text/paragraph. <br> tag
is used for a line break in HTML. Ant white space between characters displays as a single
space.
i.<ul>
<p>Option one </p>
</ul>
ii.<ul>
<li>Option two </li>
</ul>
a) i
b) ii
c) i and ii
d) Neither i nor ii
View Answer
Answer: b
Explanation: Content model specifies that certain elements are supposed to occur only
within other elements. The <ul> tag which is for unordered list should contain <li> tags
which are for list specification. The <p> tag is used for paragraph in HTML.
a) <hr/>
b) <br/>
c) <p/>
d) Both <hr/> and <br/>
View Answer
Answer: c
Explanation: An element is said to be empty if it doesn’t contain any content in it. The <hr/>
and <br/> tag which is used for a horizontal line and line break respectively, doen’t contains
any content in it and thus are called empty elements in HTML. <p> tag contains
text/paragraph in it so it’s not an empty element.
6. State true or false.
a) True
b) False
View Answer
Answer: b
Explanation: As a block tag, <p> induces a return by default, but when used repeatedly, like
<p></p><p></p>, it does not have any effect on document.
a) i
b) ii
c) i and ii
d) Neither i nor ii
View Answer
Answer: b
Explanation: In markup, tags can be nested. The first tag who is going to nest other tag
must end after that nested tag which means if <i> tag is nested in <b> tag then <b> must be
closed after closing of the <i> tag.
a) >
b) >
c) <
d) &st;
View Answer
Answer: d
Explanation: Character escapes in markup is to represent any Unicode character in HTML,
XHTML or XML using only ASCII characters. There are different types of escape character
entity in HTML. Some of them are > which is used for greater than(>) , > is basically a entity
number which is used for greater than(>), < stands for less than(<), etc. There doesn’t exist
any &st escape character entity in markup.
10. Identify the count of mistakes in the following markup.
<html>
<head>
</head>
<body>
<li>
<ul><p>Hello</p></ul>
</li>
<br>
<hr>
</body>
</html>
a) 2
b) 3
c) 1
d) 0
View Answer
Answer: b
3. State true or false. It is faster to render HTML and CSS than to interpret and execute
JavaScript.
a) True
b) False
View Answer
Answer: a
Explanation: When it comes to ordering your CSS and JavaScript, you want your CSS to
come first. The reason is that the rendering thread has all the style information it needs to
render the page. If the JavaScript includes come first, the JavaScript engine has to parse it
all before continuing on to the next set of resources.
advertisement
6. Which of the following is used to read a HTML page and render it?
a) Web browser
b) Web server
c) Web matrix
d) Web network
View Answer
Answer: a
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 client as per their request. Web matrix is a
discontinued cloud-connected website builder and HTML editor for Windows.
3. We can define ________ number of sites with one copy of dreamweaver installed on our
computer.
a) 990
b) 10
c) only 1
d) unlimited
View Answer
Answer: d
Explanation: Dreamweaver is an IDE to build custom web apps and applications. There is
no definite liit to it.
advertisement
7. Choose the inappropriate option with respect to Blue Griffon 1.5.2. Blue Griffon
_________
a) includes tools for developing HTML5 pages
b) abstracts out many css3 effects
c) supports direct embedding of audio and video files
d) supports swapping of videos of any length
View Answer
Answer: d
Explanation: Blue Griffon 1.5.2 is a new WYSIWYG content editor for the World Wide Web.
Blue Griffon 1.5.2 includes tools for developing HTML5 pages. It can abstracts out many
CSS3 effects, supports direct embedding of audio and video files. Blue Griffon 1.5.2 does
not support swapping of videos of any length.
8. Maqetta is an open source initiative of the Dojo Foundation to geared towards visual
designers through a WYSIWYG user interface.
a) True
b) False
View Answer
Answer: a
Explanation: Maqetta is an open source initiative of the Dojo Foundation to build an HTML5-
based editor geared towards visual designers through a WYSIWYG user interface. Maqetta
was developed by IBM and then donated to the Dojo.
2. Tomcat is an open source web server that provides a servlet container allowing you to
run Java code.
a) True
b) False
View Answer
Answer: a
Explanation: Apache Tomcat, a web server developed by the Apache Software Foundation
and which is also known as Tomcat Server. Apache Tomcat provides several Java EE
specifications such as Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket. It
also provides “Java” HTTP web server which is used to run java code.
6. Google Chrome has its own task manager, which allows you to view and manage your
memory and CPU usage.
a) True
b) False
View Answer
Answer: a
Explanation: A task manager provides many functions to us including, managing
applications, handling running pc, providing informative statistics, enabling computer on or
off, etc. Google Chrome also has a task manager, which allows you to view and manage
your memory and CPU usage.
7. Which of the following are automatically loaded and operates as a part of browser?
a) Add-ons
b) Plug-ins
c) Utilities
d) Widgets
View Answer
Answer: b
Explanation: Functionality of firefox can be extended as well as modified by using Add-ons.
Plugin programs operates as a part of browser. A utility provides an addition to the
capabilities provided by the operating system. A widget is a simple application extension
that is already installed on the device.
9. What is DOM?
a) Hierarchy of objects in ASP.NET
b) Application programming interface
c) Convention for representing and interacting with objects in html documents
d) Language dependent application programming
View Answer
Answer: c
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.
10.
1. Which one of the following is an open source JavaScript library that enables styling for
HTML5 elements in versions of Internet Explorer before IE 9 ?
a) HTML5
b) HTML5 Shiv
c) HTML5 Shim
d) HTML5 Sham
View Answer
Answer: b
Explanation: HTML5 Shiv is a JavaScript workaround, invented by Sjoerd Visscher, to
enable styling of HTML5 elements in versions of Internet Explorer prior to version 9, which
do not allow unknown elements to be styled without JavaScript. HTML 5 defines the
properties and behaviors of web page content. It is a web language.
2. Which one of the following is not a step to install a library you need to perform the
compatibility in browsers?
a) Download the library from the github location
b) Uncompress the file
c) Insert the following code inside the head tag
d) None of the mentioned
View Answer
Answer: d
Explanation: All steps are required.
3. Which property is used to detect the browser’s user agent and code based on the
pertinent cases?
a) navigator.userAgent
b) navigator.user
c) navigator
d) return
View Answer
Answer: a
Explanation: An old strategy was to look at the property navigator.userAgent to detect the
browser’s user agent and code based on the pertinent cases.
advertisement
4. Some users have requested tests for IE’s float double margin bug, and support for
position:fixed. Which API is suitable for them?
a) mq() media Plugin API
b) addTest() Plugin API
c) testAllProps() Plugin API
d) none of the mentioned
View Answer
Answer: b
Explanation: The navigator object contains information about the browser. UseAgent
property gives user-agent header sent by browser to the server. A navigator.userAgent is
used to detect the browser’s user agent and code based on the pertinent cases.
5. ___________ is an open source JavaScript library that allows support for different levels
of experiences based on the capabilities of each browser.
a) Navigator
b) Modernizr
c) Geolocation
d) Google API
View Answer
Answer: b
Explanation: Modernizr is an open source JavaScript library that allows support for different
levels of experiences based on the capabilities of each browser using a simple feature
detection model. Geolocation is the identification of geographic location of an object. The
navigator object contains information about the browser. Google API, i.e set of application
programming interface which allow communication with Google Services & integration to
other services.
6. ____________ allows you to add custom styles to the document and test an element
afterwards.
a) hasEvent()
b) testAllProps()
c) testProp()
d) modernizr.testStyles()
View Answer
Answer: d
Explanation: Modernizr.testStyles() allows you to add custom styles to the document and
test an element afterwards. An element with the id of “modernizr” is injected into the page.
7. Modernizr does actually add missing functionalities to browsers save for the HTML5 tags
styling support.
a) True
b) False
View Answer
Answer: b
Explanation: Modernizr is a JavaScript library which is designed to detect HTML5 and CSS3
features in various browsers, which lets JavaScript avoid using unimplemented features or
use a workaround such as a shim to emulate them. Modernizr, in spite of its name, does not
actually add missing functionalities to browsers save for the HTML5 tags styling support.
9. ____________ is a resource loader (CSS and JavaScript) that was made to specifically
to work side-by-side with Modernizr.
a) HasEvent()
b) Navigator.userAgent
c) Modernizr.load
d) Modernizer.geolocation
View Answer
Answer: c
Explanation: Modernizr.load is optional in your build, but if you are loading polyfills, there’s a
good chance it can save you some bandwidth and boost performance a bit. Modernizr.load
objects print out on your page in the exact spot they should be, coming after the Modernizr.
1. Metadata store information about the web page that is not necessarily visible to end
users.
a) True
b) False
View Answer
Answer: a
Explanation: Metadata is “data [information] that provides information about other data.
Meta tags store information about the web page—known as metadata that is not
necessarily visible to end users (unless you reveal the page source code).
7. ___________ prevents search engines from following links inside the page.
a) noarchive
b) nofollow
c) noindex
d) novalue
View Answer
Answer: b
Explanation: NOFOLLOW attribute instruct search engines that a hyperlink should not
influence the link target’s ranking in search engine. NOINDEX prevents page from being
indexed. To prevent a page from being cracked, NOARCHIEVE tag can be used.
8. Different meta tags are defined by changing the __________ attribute to a valid value.
a) scheme
b) content
c) http-equiv
d) name
View Answer
Answer: d
Explanation: The information/value of the content is provided by http-equiv through http
header. Some values associated with http-equiv and name attribute are given by the
content attribute. A scheme that to be used to interpret the value of the content is specified
by the scheme tag. The name attribute specifies the name of input element and thus
provides information/value of it.
9. __________ prevents search engines from showing a cached link for the page.
a) nobot
b) nofollow
c) noarchive
d) nosearch
View Answer
Answer: c
Explanation: The “noarchive” meta tag is used to tell browsers not to store cached link for
the page. A “nofollow” attribute instruct search engines that a hyperlink should not influence
the link target’s ranking in search engine. The “noindex” prevents page from being indexed.
10. The value of the ___________ attribute refers to the time interval in seconds before the
refresh is performed.
a) scheme
b) content
c) http-equiv
d) name
View Answer
Answer: b
4. Which of the following is true if the property value of a name-value pair added by an
element with an itemprop attribute is a meta element?
a) The value is the item created by the element
b) The value is the value of the element’s value attribute, if it has one, or the empty string
otherwise
c) On getting, if the element has a datetime content attribute, the IDL attribute must return
that content attribute’s value
d) The value is the element’s textContent
View Answer
Answer: b
Explanation: When the property value of a name-value pair added by an element with an
itemprop attribute which is a meta element then the value is the value of the element’s value
attribute, if it has one, or the empty string otherwise. The “itemprop” attribute is a global
attribute which adds properties to item.
5. Which of the following is true if the property value of a name-value pair added by an
element with an itemprop attribute is a time element?
a) The value is the element’s datetime value
b) The value is the value of the element’s content attribute, if any, or the empty string if
there is no such attribute
c) The value is the value of the element’s value attribute, if it has one, or the empty string
otherwise
d) The value is the element’s textContent
View Answer
Answer: a
Explanation: The “itemprop” attribute is a global attribute which adds properties to item.
When the property value of a name-value pair added by an element with an itemprop
attribute which is a time element then the value is the element’s datetime value.
7. If the element has an itemscope attribute, it returns an __________ object with all the
element’s properties.
a) itemscope
b) dom object
c) collection.namedItem
d) itemtype
View Answer
Answer: b
Explanation: When an HTML document is loaded into a web browser, it becomes a
document object. In web browser, document model represents document as a logical tree.
The “itemscope” attribute which is of boolean type is used to state the scope of metadata.
8. Which of the following is true if the property value of a name-value pair added by an
element with an itemprop attribute is a data element?
a) The value is the value of the element’s value attribute if it has one, or the empty string
otherwise
b) The value is the item created by the element
c) The value is the element’s datetime value
d) The value is item’s scope
View Answer
Answer: a
Explanation: The “itemprop” attribute is a global attribute which adds properties to item.
When the property value of a name-value pair added by an element with an itemprop
attribute which is a data element then the value is the value of the element’s value attribute
if it has one, or the empty string otherwise.
9. Which method takes a string that contains an unordered set of unique space-separated
tokens that are case-sensitive, representing types?
a) document.getItems
b) element.itemProp
c) collection.namedItem
d) object.itemref
View Answer
Answer: a
Explanation: When called, the method must return a live NodeList object containing all the
elements in the document, in tree order, that are each top-level microdata items whose
types include all the types specified in the method’s argument, having obtained the types by
splitting the string on spaces.
10. The goal of microdata is to create a unified way to define the data in a way any web
crawler or reader implementation can read it.
a) True
b) False
View Answer
Answer: a
9. In March 1999, Microsoft released Internet Explorer 5, which supported favicons for the
first time.
a) True
b) False
View Answer
Answer: a
Explanation: Favicons are graphical interface given to a site. Firstly, in 1999, favicon was
supported by Internet Explorer 5 which was owned by Microsoft. Later on, in 1999 favicon
was standardized by the W3C.
10. A favicon is an image used by the browser to identify a website or web application.
a) True
b) False
View Answer
Answer: a
1. Which tag is used if you want to highlight something that is important to the reader?
a) <b>
b) <strong>
c) <em>
d) <i>
View Answer
Answer: a
Explanation: : The <b> tag is used to make the text bold. The <strong> tag is used to
highlight the importance of text. The <em> tag is emphasis tag and is displayed in italic by
browser. <i> tag is used to write text in italic font.
2. Which tag is not used if you want to indicate the importance of the phrase?
a) <i>
b) <h1>
c) <em>
d) <strong>
View Answer
Answer: a
Explanation: Tags like <h1> (including all headings from h1 to h6), <em> and <strong> can
be used to indicate the importance of the phrase. The <i> is none other than a type of font
displaced in italic bond by the browsers.
3. Which of the following statement is not true?
a) XHTML DOCTYPE is mandatory
b) The xmlns attribute in <html> is mandatory
c) <html>, <head>, <title>, and <body> are mandatory
d) None of the mentioned
View Answer
Answer: d
Explanation: XHTML is a markup language. There are certain terms and conditions (rules
and regulations) for it. There are as: 1) In XHTML, the DOCTYPE is compulsory, 2) Xmlns
attribute in <html> in manndatory, 3) The basic building blocks of markup i.e. <html>,
<head>, <title>, and <body> are must in one. 4) Last but not least, XHTML is case sensitive
where as HTML is case in-sensitive.
4. According to the rules of XML and XHTML, all elements must be closed either with an
end tag or by self-closing with space, slash, and a right-pointing angle bracket.
a) True
b) False
View Answer
Answer: a
Explanation: XML and XHTML are markup languages used for creating web pages. XHTML
is case sensitive, and thus they must be closed either an end tag or by self-closing with a
space, slash, and a right pointing angle bracket. Ex) <p></p> is paragraph tag closed with
ending tag. <br/> is break tag whose closing is done either by a slash or right pointing angle
bracket.
advertisement
7. The root element of an XHTML document must be html, and must contain an
__________ attribute to associate it with the XHTML namespace.
a) source
b) src
c) xmlns
d) link
View Answer
Answer: c
Explanation: The xmlns attribute specifies the xml namespace for a document. It is
manadatory in XHTML while in HTML5 it is optional. The root element of an XHTML
document must be html, and must contain an xmlns atrribute to associate it with the XHTML
namespace.
9. __________ is an extended version of the XHTML markup language for supporting RDF
through a collection of attributes and processing rules in the form of well-formed XML
documents.
a) XHTML + RDFa
b) XHTML+XHTML5
c) XHTML1.0+XHTML2.0
d) XHTML + RDF
View Answer
Answer: a
Explanation: XHTML+RDFa (Extensible Hypertext Markup Language + Resource
Description Framework in attributes) is an extended version of the XHTML markup
language for supporting RDF through a collection of attributes and processing rules in the
form of well-formed XML documents.
3. What application can one create even before the introduction of HTML5?
a) Web applications
b) Mobile applications
c) Forms
d) Browser based games
View Answer
Answer: c
Explanation: With the help of HTML5 and JavaScript it became possible to create excellent
mobile applications, browser based games, web applications and many more other
applications. Forms were already introduced before HTML5.
advertisement
5. What if one does not use the doctype in the starting of HTML document?
a) Browser finds the document in quirky mode
b) Browser finds a document in standard mode
c) Browser stops working
d) Browser crashes after showing the page
View Answer
Answer: a
Explanation: If the browser finds <!doctype html> in the starting of an HTML document it
sets the document in standard mode but if one does not use a doctype, the browser goes to
quirky mode. In this mode, certain content will not be displayed as per one wrote that. So it
is always recommended to write a doctype at the very start of the HTML document.
4. Which of the following are not the valid character set in HTTP?
a) ISO-8859-1
b) US-ASCII
c) ISO-8859-7
d) ISO-8859-12
View Answer
Answer: d
Explanation: A character set must know to web browsers to display HTML pages correctly.
For the preference of clients we use character sets for specifying characters. The default
value is US-ASCII. The valid character sets are ISO-8859-1, US-ASCII or ISO-8859-7.
8. Which symbol is used when HTTP request does not apply to the particular source?
a) ‘&’
b) ‘*’
c) ‘#’
d) ‘@’
View Answer
Answer: b
Explanation: When HTTP request does not apply to particular resource ‘*’ is used. It is
applied to the server itself. This is only allowed when the used method is not necessarily
applied to the resource. E.g. OPTIONS * HTTP/1.1
9. Which of the following is not a request-header field?
a) Expect
b) Host
c) Delete
d) If-None-Match
View Answer
Answer: c
Explanation: For passing additional information about request we use request-header fields.
These are also requested modifiers. There are several request-header fields like Accept-
Encoding, Expect, Accept-Charset, Accept-Language, Form, Host, Authorization, If-Match,
Proxy-Authorization, Range, User-Agent, TE, Referer, If-Unmodified-Since, If-Range.
1. Which of the following element represents a thematic break rather than a horizontal rule,
though that is the likely representation?
a) <dd>
b) <dt>
c) <hr>
d) <menu>
View Answer
Answer: c
Explanation: The <dd> & <dt> tag defines names/terms. <menu> tag in HTML is for list of
commands. The hr tag defines a thematic break in an HTML page (e.g. a shift of topic).
Thematic is break between paragraph-level elements.
2. Which of the following element was redefined to represent user interface menus,
including context menus?
a) <ul>
b) <dt>
c) <hr>
d) <menu>
View Answer
Answer: d
Explanation: <dt> tag defines terms/names. The <hr> tag is used for thematic break
between paragraph-level. <ul> tag is used to represent list of items/objects. <menu> tag in
HTML is for list of commands. The menu tag is used for context menus, toolbars and for
listing form controls and commands.
3. Which of the following HTML 4 attributes is not removed in HTML5?
a) text
b) rules
c) link
d) mark
View Answer
Answer: d
Explanation: Mark attribute is still used in HTML5 but rest of attributes i.e. text, rules, link
are deprecated in HTML5.
advertisement
7. Which of the following element represents the header of a section or the document and
contains a label or other heading information for the related content?
a) data-X
b) header
c) mark
d) meter
View Answer
Answer: b
Explanation: Data-X element consist of data. The mark element indicates
highlighted/marked text. The header element represents a container for introductory content
or a set of navigational links.
9. _____________ defines a group of content that should be used as a figure and may be
labeled by a legend element.
a) figure
b) details
c) output
d) aside
View Answer
Answer: a
1. Which element is used to define a discrete unit of content such as a blogpost, comment,
and so on?
a) section
b) class
c) article
d) media
View Answer
Answer: c
Explanation: Sections in document is made by the section tag. The class attribute specifies
one or more class names to HTML. An article element is semantic element and it contains a
standalone piece of content that would make sense if syndicated as an RSS item, for
example a news item.
2. HTML5 documents may contains a ___________ element, which is used to set the
header section of a document.
a) header
b) footer
c) section
d) drive
View Answer
Answer: a
Explanation: Section element is used to make sections in document. The copyright/footer
information is provided by footer element in HTML5. A header for document section is given
by header element. The header tag is used to contain the header content of a site.
3. Which element may be used within content to represent material that is tangential?
a) aside
b) cite
c) article
d) class
View Answer
Answer: a
Explanation: <cite> tag defines the title of work. The class attribute specifies one or more
class names to HTML. An article tag is similar to <section> or <header> which contains
information. The aside tag defines a block of content that is related to the main content
around it, but not central to the flow of it.
advertisement
4. ____________ contains the navigation menu, or other navigation functionality for the
page.
a) section
b) header
c) nav
d) aside
View Answer
Answer: c
Explanation: The nav element is for marking up the navigation links or other constructs (eg
a search form) that will take you to different pages of the current site, or different areas of
the current page. Header contains section of headings. Section element is used to make
sections in document. The aside tag defines a block of content that is related to the main
content around it, but not central to the flow of it.
6. The element ___________ simply groups items within an enclosed dd tag, though it may
associate them with a caption defined by a dt tag.
a) object
b) figure
c) embed
d) collect
View Answer
Answer: a
Explanation: HTML documents are delivered as “documents”.These are then parsed, which
turns them into the Document Object Model (DOM) internal representation, within the web
browser. A self-contained information like images, diagrams are specified by figure tag in
HTML. External applications are embed using embed tag.
7. Which of the following element is used for highlighting content similarly to how a
highlighter pen might be used on important text in a book?
a) em
b) strong
c) mark
d) bold
View Answer
Answer: c
Explanation: <em> tag convert the font in italic one. The <strong> tag is used to denote the
importance of text. <bold> tag is used to make the text bold in font size. The mark tag
defines marked text and is used to highlight parts of your text.
8. To insert a video, we use a video tag and set its src attribute to a local or remote URL
containing a playable movie.
a) True
b) False
View Answer
Answer: a
Explanation: To show a video in HTML, video element is used. One of the attribute of video
called src is used to provide the location of video i.e. it’s URL address.
9. Which tag is used to encapsulate navigation and then style the elements appropriately as
menu items?
a) ul
b) li
c) nav
d) both ul and li
View Answer
Answer: d
1. __________ can be used to advise the browser to download media content in the
background to improve playback.
a) poster
b) autobuffer
c) buffer
d) data-X
View Answer
Answer: b
Explanation: Data-X stores custom data. Buffer property is used to decide whether the
output should be buffered or not. If autobuffering attribute is used, then the video will
automatically begin to buffer even if it’s not set. It suggests to the browser that it should load
as much of the resource as possible. As long as the browser’s own media cache isn’t full, it
will keep on downloading. URL of an image is given by poster attribute until the user seek
for it.
2. The _________ element is used to render simple graphics such as line art, graphs, and
other custom graphical elements on the client side.
a) metadata
b) css
c) canvas
d) art
View Answer
Answer: c
Explanation: Metdata gives data or information of other data. CSS i.e. Cascading Style
Sheets is a style sheet language. Canvas is introduced in HTML5 for providing/drawing
graphics. The canvas element is part of HTML5 and allows for dynamic, scriptable
rendering of 2D shapes and bitmap images.
3. Prior to HTML5 in web market, traditionally, multimedia has been inserted with the
concept of tag-based multimedia back.
a) True
b) False
View Answer
Answer: b
Explanation: Multimedia has different formats, it can be anything that you can hear or see.
Traditionally, multimedia has been inserted with the embed and object elements, particularly
when inserting Adobe Flash, Apple QuickTime, Windows Media, and other formats.
advertisement
4. Consider the following markup and answer the question that follow.
What is the need to add multiple file formats for the same file?
a) To provide fallback support
b) To address the media support problem
c) To provide fallback support & address the media support problem
d) To provide foul back support
View Answer
Answer: c
Explanation: To address the media support problem, you need to add in alternative formats
to use by including a number of source tags.
View Answer
Answer: d
Explanation: Autobuffer is a attribute for both <audio> and <video>, so we can replace it
with either <audio> or <video>. As with the video element, you also have autobuffer and
autoplay attributes for the audio element.
6. Which plugins can provide the fallback support for old browsers?
a) Flash
b) Quicktime
c) Both Flash and Quicktime
d) Fireback and Quickertime
View Answer
Answer: c
Explanation: An attribute of the format: type=”application/x-shockwave-flash” will justify the
purpose.
7. Which of the following is not the promises of the open web platform?
a) Security and Privacy
b) Performance and Tuning
c) Media and Real-Time Communications
d) Device Interconnection
View Answer
Answer: d
Explanation: The different promises of the open web platform are –
• Security and Privacy
• Core Web Design and Development
• Device Interaction
• Application Lifecycle
• Media and Real-Time Communications
• Performance and Tuning
• Usability and Accessibility
• Services
8. HTML5 brings to the Web video and audio tracks without needing plugins.
a) True
b) False
View Answer
Answer: a
2. __________ is a JavaScript library that implements the most common user interface
elements and interactions like sliders, accordions, tabs, and so on.
a) JavaScript
b) JQuery UI
c) VTS
d) JCL
View Answer
Answer: b
Explanation: JQuery UI is a curated set of user interface interactions, effects, widgets, and
themes built on top of the jQuery JavaScript Library. JavaScript is a scripting language. VTS
is a powerful rendering engine browser for JavaScript. JCL is Job Control Language which
is also named as scripting language.
3. In HTML Audio/Video DOM, __________ sets or returns whether the audio/video should
be loaded when the page loads.
a) preload
b) autoplay
c) buffered
d) controller
View Answer
Answer: a
Explanation: Autoplay, preload, buffered, controller etc are the different kinds of attribute of
video/audio element. Using autoplay, video/audio automatically begins to play. The preload
property allows the author to provide a hint to the browser about what he/she thinks will lead
to the best user experience. This attribute may be ignored in some instances.
advertisement
View Answer
Answer: d
Explanation: <video> tag is used to display video clips in HTML5. Multiple media resources
for media elements is specified by <source> tag. Text track for media elements i.e. <audio>
& <video> is provided by <track> tag in HTML5. There is no such thing as slider tag in
HTML5.
5. What will happen if height and width of video are not set while video loads?
a) page flickers
b) page does not load
c) page crash
d) page closes
View Answer
Answer: a
Explanation: If height and width are not set, the browser does not know the size of the
video. The effect will be that the page will change (or flicker) while the video loads.
6. Which of the following HTML Video – Media Type is not supported in IE?
a) WebM
b) MP4
c) Ogg
d) MP4 FLAC
View Answer
Answer: c
Explanation: The Ogg container format with the Theora video codec and the Vorbis audio
codec is supported in desktop/mobile Gecko (Firefox), Chrome, and Opera, and support for
the format can be added to Safari (but not on iOS) by installing an add-on. The format is not
supported in Internet Explorer in any way. The most widely used format for HTMl video i.e
MP4 format is supported in IE.
7. In HTML Audio/Video DOM, __________ sets or returns the default speed of the
audio/video playback.
a) currentTime
b) duration
c) defaultPlaybackRate
d) playbackRate
View Answer
Answer: c
Explanation: CurrentTime set or returns current playback position while playing audio/video.
The length of the current audio/video is set or returned by duration. Default speed of
playback is given by defaultPlaybackRate while playback returns speed of the audio/video.
8. In HTML Audio/Video DOM, __________ sets or returns the CORS settings of the
audio/video.
a) currentTime
b) duration
c) defaultPlaybackRate
d) crossOrigin
View Answer
Answer: d
Explanation: CurrentTime set or returns current playback position while playing audio/video.
The length of the current audio/video is set or returned by duration. Default speed of
playback is given by defaultPlaybackRate. The purpose of the crossorigin attribute is to
allow you to configure the CORS requests for the element’s fetched data.
a) <bgsound>
b) <audio>
c) <video>
d) <canvas>
View Answer
Answer: b
Explanation: <video> tag is used for video clips in HTML5. <canvas> is for graphical user
interface. The audio tag defines sound, such as music or other audio streams.
3. Which tag is used to defines multiple media resources for media elements audio and
video?
advertisement
a) <source>
b) <canvas>
c) <audio>
d) <video>
View Answer
Answer: a
Explanation: <video> tag is used for video clips in HTML5. <canvas> is for graphical user
interface. The audio tag defines sound, such as music or other audio streams.defines
multiple media resources for media elements, such as <video> and <audio>.
4. Which of the following browser does not support wav file format?
a) Opera
b) Firefox
c) Chrome
d) Internet Explorer
View Answer
Answer: d
Explanation: Opera, firefox, chrome and internet explorer are different kinds of browsers.
Out of which audio file format named wav is not supported by internet explorer.
5. In HTML Audio/Video DOM __________ sets or returns the volume of the audio/video.
a) src
b) volume controls
c) volume
d) video Tracks
View Answer
Answer: c
Explanation: Src attribute gives current source of audio/video element. The videoTrack list
is returned representing available video tracks by video track attribute. Volume attribute sets
the current volume of video/audio.
6. Which of the following attribute adds audio controls, like play, pause, and volume?
a) audio
b) controls
c) source
d) src
View Answer
Answer: b
Explanation: The audio attribute defines sound, such as music or other audio streams.
Source attribute defines multiple media resources for media elements, such as <video> and
<audio>. Src attribute gives current source of audio/video element. The controls attribute is
a boolean attribute. When present, it specifies that audio controls should be displayed.
7. In HTML Audio/Video DOM __________ sets or returns whether the audio/video should
start playing as soon as it is loaded.
a) controls
b) audio Tracks
c) autoplay
d) currentSrc
View Answer
Answer: c
Explanation: Control attribute is used to set whether audio/video should display controls.
AudioTrack list representing audio tracks is set by audio track. The autoplay attribute is a
boolean attribute. When present, the audio will automatically start playing as soon as it can
do so without stopping. A current src of audio/video is returned by currentSrc.
8. In HTML Audio/Video DOM __________ sets or returns whether the audio/video should
start over again when finished.
a) loop
b) autoplay
c) seeking
d) played
View Answer
Answer: a
Explanation: The loop attribute is a boolean attribute. When present, it specifies that the
audio will start over again, every time it is finished. With autoplay, it ensures whether
video/audio should play immediately after loading page. Seeking returns whether user is
currently seeking video/audio. Timeranges representing played parts of audio/video is set
by played attribute.
10. In HTML Audio/Video DOM __________ returns a TextTrackList object representing the
available text tracks.
a) readyState
b) startDate
c) videoTracks
d) textTracks
View Answer
Answer: d
a) <paint>
b) <canvas>
c) <graphic>
d) <css>
View Answer
Answer: b
Explanation: CSS i.e. Cascading Style Sheet is a scripting language. Canvas graphics is
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).
2. Which of the following statement is not true?
a) SVG stands for Scalable Vector Graphics
b) SVG is used to define graphics for the Web
c) SVG is a W3C recommendation
d) SVG doesn’t support event handlers
View Answer
Answer: d
Explanation: SVG stands for “Scalable Vector Graphics”, it is used to draw graphics for the
web. W3C recommends SVG graphics. SVG also supports event handlers which is not
supported in canvas.
advertisement
3. To draw on the canvas, authors must first obtain a reference to a context using the
______________ method of the canvas interface element.
a) getImageData
b) toDataURL
c) getContext
d) restore
View Answer
Answer: c
Explanation: The method getImageData(), returns an imageData that copies pixel data for a
specified thing in canvas. ContextType is a DOMString containing the context identifier
defining the drawing context associated to the canvas.
4. The ___________ method must add the scaling transformation described by the
arguments to the transformation matrix.
a) scale(x, y)
b) translate(x, y)
c) rotate(angle)
d) skew(x,y)
View Answer
Answer: a
Explanation: HTML5 canvas provides scale(x, y) method which is used to increase or
decrease the units in our canvas grid. The position (0, 0) is remaped in canvas by
translate(x, y) method. If one want to rotate the current drawing then rotate(angle) method
can be used.
5. Which method must clear the pixels in the specified rectangle that also intersects the
current clipping region to a fully transparent black, erasing any previous image?
a) strokeRect(x, y, w, h)
b) clearRect(x, y, w, h)
c) fillRect(x, y, w, h)
d) removeRect(x,y,w,h)
View Answer
Answer: b
Explanation: StrokeRect(x, y, w, h) draws rectangle without filling it. The clearRect() method
clears the specified pixels within a given rectangle. FillRect(x, y, w, h) method draws filled
rectangle.
6. When the _____________ method is passed an animated image as its image argument,
the user agent must use the poster frame of the animation, or, if there is no poster frame,
the first frame of the animation.
a) measureText()
b) imageData()
c) drawImage()
d) setImage()
View Answer
Answer: c
Explanation: The width of specified text present in an object is given by measureText()
method. The drawImage() method draws an image, canvas, or video onto the canvas.
ImageData() method provides image data in pixels in canvas.
7. The ____________ method must create a new clipping region by calculating the
intersection of the current clipping region and the area described by the current path, using
the non-zero winding number rule.
a) fill()
b) stroke()
c) clip()
d) get()
View Answer
Answer: c
Explanation: The path one defines is drawn by stroke() method. Any region/shape or size in
canvas is clipped by clip(). The fill() method fills the current drawing (path). The default color
is black. There is no method like get().
8. The ____________ method must fill all the subpaths of the current path, using fillStyle,
and using the non-zero winding number rule.
a) fill()
b) stroke()
c) clip()
d) get()
View Answer
Answer: a
Explanation: The path one defines is drawn by stroke() method. Any region/shape or size in
canvas is clipped by clip(). The fill() method fills the current drawing (path). The default color
is black. There is no method like get().
9. Which of the following methods must empty the list of subpaths so that the context once
again has zero subpaths?
a) closePath()
b) beginPath()
c) moveTo(x, y)
d) endPath()
View Answer
Answer: b
Explanation: ClosePath() creates a path that starts from current point up to the starting
point. The beginPath() method begins a path, or resets the current path. MoveTo(x, y)
moves the point specified in canvas but without creating the line. There is nothing like
endPath() in canvas.
2. The new __________ element is supposed to represent some form of extra details, such
as a tooltip or revealed region that may be shown to a user.
a) progress
b) meter
c) details
d) menu
View Answer
Answer: c
Explanation: A scalar measurement within a range or fractional value is defined by meter
tag. A list/menu of coommands is displayed by menu tag in html. The details tag specifies
additional details that the user can view or hide on demand. The details tag can be used to
create an interactive widget that the user can open and close. Any sort of content can be
put inside the <details> tag. Progress of a task is done by progress element.
3. The __________ element may contain not just links but also other interactive items,
including the newly introduced command element.
a) progress
b) meter
c) details
d) menu
View Answer
Answer: d
Explanation: A scalar measurement within a range or fractional value is defined by meter
tag. The menu tag defines a list/menu of commands. The menu tag is used for context
menus, toolbars and for listing form controls and commands. The details tag specifies
additional details that the user can view or hide on demand. The details tag can be used to
create an interactive widget that the user can open and close. Any sort of content can be
put inside the <details> tag. Progress of a task is done by progress element.
advertisement
4. The __________ attribute effectively renders the iframe as an inline include, which allows
the parent document’s CSS to affect the contents of the iframe.
a) allow-forms
b) seamless
c) embed
d) allow-scripts
View Answer
Answer: b
Explanation: Embed attribute attach external content at a specified point in document. The
seamless attribute is a boolean attribute. When present, it specifies that the iframe should
look like it is a part of the containing document (no borders or scrollbars). Allow-forms re-
enables from submission. Scripts are re-enabled by allow-scripts.
5. Which of the following allows the sandboxed iframe to run scripts from the same domain?
a) allow-same-origin
b) allow-forms
c) allow-scripts
d) allow-pointer-lock
View Answer
Answer: c
Explanation: Scripts are re-enabled by allow-scripts. The sandbox attribute enables an extra
set of restrictions for the content in the iframe. Allow-forms re-enables from submission.
Allow-same-origin allows iframe content to be treated as being from the same origin. API’s
are re-enable by allow-pointer-lock.
6. __________ allows the iframe to pull in content from elsewhere in the same domain.
a) allow-same-origin
b) allow-forms
c) allow-scripts
d) allow-pointer-lock
View Answer
Answer: a
Explanation: Scripts are re-enabled by allow-scripts. Allow-forms re-enables from
submission. Allow-same-origin allows iframe content to be treated as being from the same
origin. API’s are re-enable by allow-pointer-lock.
a) <datalist>
b) <keygen>
c) <output>
d) <password>
View Answer
Answer: d
Explanation: <datalist>, <keygen> and <output> are HTML5 added form element. Element
<password> is not a HTML5 added form element. Password is an attribute used in input
type in HTML.
8. Which element specifies a list of pre-defined options for an input element?
a) <datalist>
b) <keygen>
c) <output>
d) <password>
View Answer
Answer: a
Explanation: The datalist tag is used to provide an “autocomplete” feature on input
elements. Users will see a drop-down list of pre-defined options as they input data.
Password defines password field in HTML. It is attribute for input-type. The <keygen>
element references from data after form has submitted. Result of calculation (script) is
represented by output tag.
9. Which of the following defines a group of related options in a drop-down list?
a) <form>
b) <optgroup>
c) <output>
d) <option>
View Answer
Answer: b
5. Which of the following does not lie under the attribute of <input> and is not supported by
Opera?
a) url
b) time
c) tel
d) option
View Answer
Answer: d
Explanation: <input> element type has new values as ‘url’, ‘email’, ‘datetime’, ‘date’, ‘month’,
‘tel’, ‘time’, ‘number’, ‘search’, ‘color’, ‘range’, ‘datetime-local’, ‘week’.
6. Which is the new attribute of <input> element that is used to change the appearance of
checkbox?
a) Indeterminate
b) Media
c) EI
d) Target
View Answer
Answer: a
Explanation: The indeterminate is actually not an attribute, it is the property of checkbox
which can be change via JavaScript, e.g. Var checkbox=document.getElementById(“any-
checkbox”); Checkbox.indeterminate=true;
7. Which attribute does not lie inside <a> and <area> elements?
a) Media
b) Ping
c) Hreflang
d) Preload
View Answer
Answer: d
Explanation: Preload is the attribute of the <video> element. Media, ping, hreflang, rel are
the attribute used with <a> and <area> elements.
10. Which attribute of <input> element can be used both with <datalist> and <select>
elements?
a) List
b) Pattern
c) Multiple
d) Max
View Answer
Answer: a
Explanation: List is the new attribute of <input> element and can be used together with
<datalist> and <select> elements. Other attributes like pattern, multiple, max, min, step are
new attribute used with the <input> element only.
12. Which of the following is not the keyword of form method attribute?
a) GET
b) POST
c) PUT
d) OUT
View Answer
Answer: d
Explanation: The keyword GET, POST, PUT, DELETE mapped to the state GET, POST,
PUT, DELETE and indicating the HTTP method respectively.
1. All elements are identified by their __________ and are marked up using either start tags
and end tags or self-closing tags.
a) attribute name
b) tag name
c) class name
d) none of the mentioned
View Answer
Answer: b
Explanation: The attribute name describes name of <input> element. The tagName property
returns the tag name of the element. In HTML, the returned value of the tagName property
is always in UPPERCASE. Name of class is returned by class name.
2. The __________ element represents a span of text that is isolated from its surroundings
for the purposes of bidirectional text formatting.
a) b
b) bdi
c) bdo
d) base
View Answer
Answer: b
Explanation: The base Url target relative to all URL’s in document is specified by base tag in
html. B is for bold text representation. bdi stands for Bi-directional Isolation. This element is
useful when embedding user-generated content with an unknown directionality. Direction of
text is displayed by bdo element.
3. The interactive element audio with the attribute controls must not appear as a
descendant of which element?
a) a
b) button
c) audio
d) both a and button
View Answer
Answer: d
Explanation: The anchor and the button tag acts as link which cannot be a parent of audio
element.
advertisement
4. A ____________ element must have a start tag but must not have an end tag.
a) details
b) command
c) code
d) both details and command
View Answer
Answer: b
Explanation: The command tag is new in HTML5 and specifies a normal command with an
action. Details has end tag.
5. Which type attribute of input element sets the element’s value to a string representing a
number?
a) range
b) email
c) file
d) date
View Answer
Answer: a
Explanation: The input element with a type attribute whose value is “range” represents an
imprecise control for setting the element’s value to a string representing a number.
6. Which of the following type attributes of input element defines control for entering a
telephone number?
a) mob
b) tel
c) mobile
d) telephone
View Answer
Answer: b
Explanation: The input element with a type attribute whose value is “tel” represents a one-
line plain-text edit control for entering a telephone number.
7. Which element represents a control for generating a public-private key pair?
a) ins
b) keygen
c) key
d) command
View Answer
Answer: b
Explanation: The command tag is new in HTML5 and specifies a normal command with an
action. The keygen element represents a control for generating a public-private key pair and
for submitting the public key from that key pair.
8. The World Wide Web’s markup language has always been HTML.
a) True
b) False
View Answer
Answer: a
Explanation: The World Wide Web’s markup language has always been HTML. HTML was
primarily designed as a language for semantically describing scientific documents, although
its general design and adaptations over the years have enabled it to be used to describe a
number of other types of documents.
10. Which element(s) represents a section of a document that links to other documents?
a) navigation
b) anchor tag
c) nav
d) option
View Answer
Answer: c
Explanation: The nav element represents a section of a page that links to other pages or to
parts within the page: a section with navigation links.
11. Which of the following element marks the ruby text component of a ruby annotation?
a) r
b) rt
c) ruby
d) rubytxt
View Answer
Answer: b
Explanation: A ruby annotation is specified by ruby text, which is small text attached to the
main text, which is used to indicate the pronunciation of characters. The rt element is the
markup for ruby text.
12. Subtitle tracks and caption tracks to be specified for audio and video elements can be
added using which of the following element?
a) sink
b) track
c) stable
d) caption
View Answer
Answer: b
3. Which of the following is the predefined shape elements that can be used by developers?
advertisement
a) Path <path>
b) Rectangle <rect>
c) Circle <circle>
d) Line <lin>
View Answer
Answer: d
Explanation: SVG images stands for Scalable Vector Graphics. Path <path> is used to
define path. Rectangle element draws rectangle and Circle <circle> draws circle in SVG. All
of the respective SVG elements are used to draw respective images.
4. Which element must reference a resource that can provide an image for the cursor
graphic?
a) hover
b) i
c) cursor
d) fill
View Answer
Answer: c
Explanation: The cursor attribute specifies the mouse cursor displayed when the mouse
pointer is over an element. This attribute behaves exactly like the css cursor property
except that if the browser supports the cursor element, you should be able to use it with the
funciri notation.
9. Which property of SVG restricts the region to which paint can be applied?
a) animateTransform
b) clip-Path
c) linearGradient
d) radialGradient
View Answer
Answer: b
Explanation: Allowing animation to control translation, scaling or rotation is done by
animateTransform element. A clipping path is defined by clip-path element. A clipping path
is defined with a clipPath element. A clipping path is used/referenced using the clip-path
property. A radialGradient lets authors define radial gradients to fill or stroke graphical
elements.
10. Which SVG element produces the same effect as if the nodes were deeply cloned into a
non-exposed DOM?
a) tref
b) use
c) stroke
d) bin
View Answer
Answer: b
1. Which of the following MP3 player has not been written in Flash?
a) musicplayer.sourceforge.net
b) www.wimpyplayer.com
c) flash-mp3-player.net
d) soundcloud.com
View Answer
Answer: d
Explanation: There are several MP3 players that have been written in Flash like flash-mp3-
player.net, www.wimpyplayer.com, musicplayer.sourceforge.net. Every player has different
functionality. So you should be aware of that. Soundcloud.com and MySpace.com are
different sites which provide a player that one can embed in the page.
4. Which element is used for inserting more than one audio file?
a) <source>
b) <src>
c) <command>
d) <ins>
View Answer
Answer: a
Explanation: <src> provides or states location i.e Url of audio file. For inserting more than
one audio file, use <source> instead of src attribute between <audio> and </audio>. This
can be important because many browser support different formats for audio. For example
MP3 is supported by Chrome6+, Safari 5+.
6. Which of the following file extension is not used for audio MIME?
a) .ogv
b) .aac
c) .wav
d) .webm
View Answer
Answer: a
Explanation: For accessing audios in different browsers we can use various extensions
like .aac, .mp1, .mp1, .m4a, .mp2, .mpg, .mp3, .mpeg, .oga, .ogg, .wav, .webm. For video
we have file extensions like .mp4, .ogv, .m4v, .webm. It is noticeable that some extensions
are common both in audio and video. So user should pay attention where to put these as
per the need.
13. Which of the following is not a Boolean attribute for <audio> element?
a) autoplay
b) loop
c) muted
d) buffered
View Answer
Answer: d
Explanation: Autoplay is a Boolean attribute and its default value is set as false. Basically,
this feature of autoplay is avoided due to the unpleasant experience of users. Loop is also a
Boolean attribute. Muted is Boolean attribute whose value is set as false by default.
Buffered is not boolean attribute in <audio> element.
sessionStorage.firstname-“Tanya”; document.getElementById(“fo”).innerHTML=
sessionStorage.firstname;
10. For clearing all the settings which function should be called?
a) localStorage.remove(key)
b) localStorage.clear()
c) localStorage.remove()
d) localStorage.clearAll()
View Answer
Answer: b
1. Which of the following is not the form type for adding text?
a) Text input
b) Text area
c) Password input
d) Submit button
View Answer
Answer: d
Explanation: There are many types of form controls. Adding text, Submitting forms, Making
choices and Uploading files are some of them. For an adding text, we can use Text input,
Text area, and Password input. For making choices there are checkboxes, radio buttons,
and drop-down boxes.
2. In the processing of information, the server does not use the language _____
a) C#
b) JAVA
c) C++
d) VB.net
View Answer
Answer: c
Explanation: When we enter a new value through form it goes to the server for processing
information and this information is processed using languages C#, PHP, JAVA or VB.net.
The database can also store the information.
3. For creating single line text box for searching queries, we use the type ___________
a) placeholder
b) search
c) url
d) hidden
View Answer
Answer: b
Explanation: For creating a single line text box for searching queries we use the
type=”search”. In old browsers, it will be simply a single line text box. Safari adds across
that clear search box when we enter new data to search. It also rounds the corners on
search input fields by default.
advertisement
for using secure HTTP connections use https: ,ws: is the new URL scheme for connecting
WebSockets. There is wss: also.
advertisement
2. The _____________ attribute specifies an inline style associated with an element, which
determines the rendering of the affected element.
a) dir
b) style
c) class
d) article
View Answer
Answer: b
Explanation: Style attribute specifies an inline style for an element. The style attribute will
override any style set globally, e.g. styles specified in the style tag or in an external style
sheet. A self-contained content is called attribute. Class is a name given to HTML elements
which can be used by CSS and JavaScript for styling the web pages. List of directory files is
given by dir tag which is not supported in HTML5.
3. Which attribute is used to provide an advisory text about an element or its contents?
a) tooltip
b) dir
c) title
d) head
View Answer
Answer: c
Explanation: The extra information about an element is specified by title tag. The
information is most often shown as a tooltip text when the mouse moves over the element.
List of directory files is given by dir tag which is not supported in HTML5. Tooltip or else
infotip is a graphical user interface of an element. Container of metadata is called head.
advertisement
4. The __________ attribute sets the text direction as related to the lang attribute.
a) lang
b) sub
c) dir
d) ds
View Answer
Answer: c
Explanation: The dir attribute specifies the text direction of the element’s content. List of
directory files is given by dir tag which is not supported in HTML5. The language of an
element’s content is given by lang attribute. The subscript text is defined by sub attribute.
5. Which of the following is the attribute that specifies the column name from the data
source object that supplies the bound data?
a) dataFormatAs
b) datafld
c) disabled
d) datasrc
View Answer
Answer: b
Explanation: DataFormatAs specifies how data is rendered. The identifier for data source is
set by dataSrc. Datafld attribute specifies the column name from the data source object that
supplies the bound data. This attribute is specific to Microsoft’s data binding. A Disabled is a
boolean attribute which specifies that <input> element should be disabled.
6. Which of the following is the attribute that indicates the name of the data source object
that supplies the data that is bound to this element?
a) dataFormatAs
b) datafld
c) disabled
d) datasrc
View Answer
Answer: d
Explanation: The identifier for data source is set by dataSrc. When the dataSrc property is
applied to a tabular data consumer, the entire data set is repeated by the consuming
elements. DataFormatAs specifies how data is rendered. A Disabled is a boolean attribute
which specifies that <input> element should be disabled.
7. Which of the following is the attribute that specifies additional horizontal space, in pixels,
to be reserved on either side of an embedded item like an iframe, applet, image, and so on?
a) height
b) hspace
c) hidefocus
d) datasrc
View Answer
Answer: b
Explanation: Height of element is pixels is specified by height attribute. The hspace attribute
specifies the whitespace on left and right side of an object. The hidefocus specifies whether
a focused rectangle is drawn around an object. The identifier for data source is set by
dataSrc.
8. The accesskey attribute specifies a keyboard navigation accelerator for the element.
a) True
b) False
View Answer
Answer: a
Explanation: The accesskey attribute specifies a shortcut key to activate/focus an element.
It specifies a keyboard navigation accelerator for the element. We can use accesskey
attribute in forms or links.
9. Which of the following is the attribute that is used to set a global identifier for a microdata
item?
a) key
b) id
c) itemclass
d) itemid
View Answer
Answer: d
Explanation: The unique id for an element in html is specified by id attribute. Itemmid allows
a vocabulary to define a global identifier for a microdata item, for example an ISBN number
on a book. Use itemid on the same element as the item’s itemscope and itemtype attributes.
10. Which of the following is the attribute that is used to add a name/value pair to a
microdata item?
a) itemscope
b) itemref
c) itemprop
d) itemid
View Answer
Answer: c
Output:
10. The major difference between minlength and min attribute is ______
a) ‘minlength’ is for the minimum number of characters and ‘min’ is for the minimum value
b) ‘minlength’ is for the minimum value and ‘min’ is for the minimum number of characters
c) ‘minlength’ is for multiple values and ‘min’ is for the single value
d) ‘minlength’ is for single value and ‘minlength’ is for multiple values
View Answer
Answer: a
Explanation: minlength attribute use with <input>, <textarea> elements and it defines
minimum number of character allowed. Min is used with <input>, <meter> elements and
indicates minimum value allowed in element.
11. loop attribute is not used with _____________
a) <audio>
b) <marquee>
c) <video>
d) <track>
View Answer
Answer: d
Explanation: loop attribute is commonly use with <audio>, <bgsound>, <video>, <marquee>
and denotes whether the media should start playing from the beginning when it is finished.
<track> element is use with default attribute and it checks whether the track is enabled or
not.
3. What should be set with text-align property so that every line has equal width like in
magazines and newspapers?
a) text-align: justify
b) text-align: none
c) text-align: bottom
d) text-align: top
View Answer
Answer: a
Explanation: By setting text-align property to “justify”, each line is stretched so that every
line has equal width, left and right margins are straight like in magazines and newspapers.
Text-align: center, text-align: right, text-align: left is also used for aligning the text at center,
right and left respectively.
advertisement
1. All attribute declarations begin with the keyword ____________ followed by the element
name, attribute name, attribute type, and default data information.
a) XML
b) SGML
c) ATTLIST
d) HTML
View Answer
Answer: c
Explanation: The ATTLIST declarations identify which element types may have attributes,
what type of attributes they may be, and what the default value of the attributes are. Syntax
is <!ATTLIST elementName attributeName dataType default >. XML and HTML are web
markup language used to design and create web pages. SGML stands for Standard
Generalized Markup Language.
2. The ________ declaration specifies which characters and delimiters may appear in the
application.
a) DTD
b) SGML
c) XML
d) HTML
View Answer
Answer: b
Explanation: XML(Extensible Markup Language) and HTML(Hypertext Markup Language)
are web markup language used to design and create web pages. The DTD defines the
syntax of markup constructs. SGML (Standard Generalized Markup Language) is a
standard for how to specify a document markup language or tag set. Such a specification is
itself a document type definition (DTD). SGML is metadata.
3. The __________ defines the syntax of markup constructs and include additional
definitions such as character entity references.
a) Attributes
b) SGML
c) Elements
d) DTD
View Answer
Answer: d
Explanation: SGML (Standard Generalized Markup Language) is a standard for how to
specify a document markup language or tag set. Property of an element is defined by the
attribute. The DTD defines the syntax of markup constructs. The DTD may include
additional definitions such as character entity references.
advertisement
4. A/An _________ is essentially a macro that allows a short name to be associated with
the replacement text.
a) Entity
b) Attribute
c) Comment
d) Element
View Answer
Answer: a
Explanation: Comments are used to provide idea about coding syntax which is ignored by
the browser. Reserved characters in HTML must be replaced with character entities.
Characters, not present on your keyboard, can also be replaced by entities. Property of an
element is defined by the attribute.
5. The ___________ keyword begins the declaration of attributes that an element may take.
It is followed by the name of the element in question, a list of attribute definitions, and a
closing.
a) DOCTYPE
b) ATTLIST
c) DTD
d) SGML
View Answer
Answer: a
Explanation: The ATTLIST declarations identify which element types may have attributes,
what type of attributes they may be, and what the default value of the attributes are. The
DTD defines the syntax of markup constructs. The DTD may include additional definitions
such as character entity references. SGML (Standard Generalized Markup Language) is a
standard for how to specify a document markup language or tag set. In HTML 4.01, the !
DOCTYPE declaration refers to a DTD, because HTML 4.01 was based on SGML. The
DTD specifies the rules for the markup language so that the browsers render the content
correctly.
8. A model group contains the names of the elements that a tag may enclose.
a) True
b) False
View Answer
Answer: a
1. Which of the following defines a part of text that might be formatted in a different direction
from other text?
a) <details>
b) <aside>
c) <bdi>
d) <article>
View Answer
Answer: c
Explanation: The additional details the user wants to know as per the demand is fulfilled by
<details> tag. Content related to surroundings is given by <aside> tag. <bdi> element is
useful when embedding user-generated content with an unknown directional. <article> is
self defined independent content which contains data which can be anything including
photos, videos, and other contents. It provides a section.
2. Which of the following defines a caption for a figure element?
a) <figcaption>
b) <dialog>
c) <caption>
d) <figure>
View Answer
Answer: a
Explanation: The figcaption element can be placed as the first or last child of the figure
element. It defines a caption for a figure element. Caption in a table immediately after
<table> tag can be given by <caption> tag. The <figure> tag provides section for illustration,
diagrams, photos etc. A box else window is defined by <dialog> tag in HTML.
3. Which of the following defines a command/menu item that the user can invoke from a
popup menu?
advertisement
a) <menuitem>
b) <menu>
c) <nav>
d) <class>
View Answer
Answer: a
Explanation: The menuitem tag is new in HTML5 and as of now is only supported in Firefox
8+ versions. <menuitem> defines a command item that the user can invoke from a popup
menu. A list of of commands is defined by <menu> tag. <nav> is set of navigation links.
One or more class names are specified by the global <class> attribute.
4. Which of the following tag defines the progress of a task?
a) <meter>
b) <progress>
c) <gauge>
d) <wbr>
View Answer
Answer: b
Explanation: Scalar measurement within range or may be a fractional value can be
displayed through <meter> tag. Use the progress tag in conjunction with JavaScript to
display the progress of a task. <wbr> is used for whether it is okay to add a line break in a
text.
5. Which of the following defines the result of a calculation?
a) <output>
b) <keygen>
c) <datalist>
d) <datalist>
View Answer
Answer: a
Explanation: The output tag represents the result of a calculation (like one performed by a
script). <keygen> has been removed from HTML5 and it specifies a name to <keygen>
element which refers to data after it’s submission. <datalist> is a list of pre-defined option
for input element. The additional details the user wants to know as per the demand is
fulfilled by <details> tag.
6. Which of the following defines graphic drawing using JavaScript?
a) <class>
b) <canvas>
c) <graphics>
d) <draw>
View Answer
Answer: b
Explanation: One or more class names are specified by the global <class> attribute. The
canvas tag is only a container for graphics, you must use a script to actually draw the
graphics. <graphics> and <draw> are imaginary part.
7. Which of the following elements in HTML5 defines video or movie content?
a) <media>
b) <video>
c) <movie>
d) <audio>
View Answer
Answer: b
Explanation: The media to which linked document is optimized is given by <media> tag.
Before HTML5, videos could only be played with a plug-in (like flash). The HTML5 video
element specifies a standard way to embed a video in a web page. As like <video>
elements, <audio> element contains additional files or streams like music, recording, etc.
8. Which of the following defines some content aside from the content it is placed in (like a
sidebar)?
a) <aside>
b) <header>
c) <sidebar>
d) <nav>
View Answer
Answer: a
Explanation: Content related to surroundings is given by <aside> tag. The aside content
should be related to the surrounding content. An introductory content is represented by
<header> element. The <nav> element contains list of navigation links.
9. Which of the following defines a visible heading for a details element?
a) <brief>
b) <summary>
c) <mark>
d) <main>
View Answer
Answer: b
Explanation: The main content of document is in <main>. <mark> is used to highlight the
text to indicate it’s uniqueness. The summary tag defines a visible heading for the details
element. The heading can be clicked to view/hide the details.
10. Which of the following defines additional details that the user can view or hide?
a) <details>
b) <article>
c) <aside>
d) <figure>
View Answer
Answer: a
1. Which event is fired as the mouse is moving over an element when a drag is occurring?
a) dragover
b) dragenter
c) dragstart
d) dragleave
View Answer
Answer: a
Explanation: The dragover event is fired as the mouse is moving over an element when a
drag is occurring. Much of the time, the operation that occurs during a listener will be the
same as the dragenter event. When draggable element enters a drop target then dragenter
event has occurred. A dragleave event occurs when it leaves the valid drop target.
Whenever a user starts to drag an element, dragstart is fired.
2. The _________ event is fired on the element where the drop occurred at the end of the
drag operation.
a) drag
b) drop
c) dragstart
d) dragenter
View Answer
Answer: b
Explanation: The drop event is fired on the element where the drop occurred at the end of
the drag operation. A listener would be responsible for retrieving the data being dragged
and inserting it at the drop location. Whenever user starts to drag an element, dragstart is
fired. When draggable element enters a drop target then dragenter event is occurred. When
element is being dragged, drag event is happened.
5. Calling the ______________ method during both a dragenter and dragover event will
indicate that a drop is allowed at that location.
a) drop
b) drag
c) preventDefault
d) dataTransfer
View Answer
Answer: c
Explanation: The drop event is fired on the element where the drop occurred at the end of
the drag operation. When element is being dragged, drag event has happened. Calling the
preventDefault method during both a dragenter and dragover event will indicate that a drop
is allowed at that location. However, you will commonly wish to call the preventDefault
method only in certain situations, for example, only if a link is being dragged. The
dataTransfer property of all drag events holds data about the drag and drop operation.
6. Which of the following property is used to determine which drag operation was desired?
a) dragend
b) getData
c) dropEffect
d) captureData
View Answer
Answer: c
Explanation: When the user finishes dragging an element, dragend is occurred. During the
drop event, you should retrieve that data that was dropped from the event and insert it at
the drop location. One can use the dropEffect property to determine which drag operation
was desired.
7. ______________ should include data of two types; the first should be the URL using the
type text/uri-list, and the second is the URL using the text/plain type.
a) Dragging HTML and XML
b) Dragging Text
c) Dragging Files
d) Dragging Links
View Answer
Answer: d
Explanation: Dragging Links should include data of two types; the first should be the URL
using the type text/uri-list, and the second is the URL using the text/plain type.
8. A listener for the dragenter and dragover events are used to indicate valid drop targets,
that is, places where dragged items may be dropped.
a) True
b) False
View Answer
Answer: a
Explanation: The dragover event is fired as the mouse is moving over an element when a
drag is occurring. Much of the time, the operation that occurs during a listener will be the
same as the dragenter event. When draggable element enters a drop target then dragenter
event is occurred.
4. Which of the following technique is not for the mobile browser to identify the location of a
user?
a) GPS
b) IP based position
c) WIFI based position
d) A-GPS
View Answer
Answer: b
Explanation: Geolocation API uses the various techniques to identify the location of a user.
In desktop browser uses IP bases position technique or WIFI. Mobile browser uses A-GPS,
WIFI based position or GPS.
11. Which is not the case of invoking for error callback function?
a) user denies to share the information of a location
b) location information is unavailable
c) request timed out
d) when we are using WIFI
View Answer
Answer: d
Explanation: Error callback function takes the Position Error object as its input parameter.
The function is invoked by an unknown error occurred or if the user has denied sharing the
information of the location or if the request timed out or if location information is unavailable.
8. If the transparent part of the image has rounded or diagonal edges, which format is
suitable?
a) PNG
b) Transparent GIF
c) GIF
d) JPG
View Answer
Answer: a
1. Which of the following gives a text description of the image if it is not available?
a) alt
b) title
c) src
d) height
View Answer
Answer: a
Explanation: The alt attributes gives a text description of the image if the image is not
available at a time. Syntax is
<img src=”apple.jpg” alt=”This is an apple, It is red” title=”apple”/>
src attribute defines the address of the image, title attribute provides some additional
information about the image. Height attribute is used to adjust the height of an image as per
need.
advertisement
1. What is Modernizr?
a) CSS style sheet
b) JavaScript Library
c) The source code of a web page
d) PHP file
View Answer
Answer: b
Explanation: Small JavaScript Library is Modernizr. It detects the availability of
implementations for new web technologies. Many browsers do not support the new features
that were introduced by HTML5. Modernizr provides a way to detect new features.
6. Which of the following can be helpful in creating your own feature detect?
a) Modernizr.addTest
b) Modenizer.on
c) Modernizr._domPrefixes
d) Modernizr.atRule
View Answer
Answer: a
Explanation: If you want to create your own feature detects you can simply use
Modernizr.addTest, a string is passed generally in lowercase without any punctuation like
Modernizr.addTest(feature, test). It returns the Boolean value. Modernizr._domPrefixes
works same as _prefixes. Modernizr.atRule is one of modernizr API(Application
Programming Interface) having syntax like – Modernizr.atRule(prop).
We should use only valid media query. Modernizr.prefixed Modernizr API takes string CSS
value in Document Object Model. Modernizr._prefixes is internal list of prefixes. To check
whether a given CSS property is supported by browser, Modernizr.testAllProps API.
9. The features that can’t be detected by checking idle are checked by ____________
a) Modernizr.prefixedCSS
b) Modernizr.testAllProps
c) Modernizr.testStyles
d) Modernizr.testProp
View Answer
Answer: c
Explanation: Modernizr.testProp is just like Modernizr.testAllProps but only difference is it
doesn’t check for vendor. The features that can’t be check by IDL is checked by
Modernizr.testStyles, it takes CSS rule and embed it onto current page with DOM elements.
Syntax is
Modernizr.testStyles (rule,callback,[nodes],[testnames]).
We can add additional div elements also on the page as per requirement.
Modernizr.prefixedCSS is same like Modernizr.prefixed except it returns result in
hyphenated form.
Modernizr.prefixed takes string css value in camelCase. Modernizr.prefixed takes string css
value in camelCase. Modernizr.prefixedCSS returns hyphenated value. Modernizr._prefixes
is internal list of prefixes.
12. Which of the following detects support for basic Worker API?
a) web workers
b) shared workers
c) data workers
d) blob workers
View Answer
Answer: a
Explanation: The support of basic web worker is detected by web workers. Web workers
mean running a script in the background for web content. Shared workers detect support of
shared workers, data workers detect support for creating Web Workers from Data URI’s.
Blob workers detect support for creating web workers from Blob URI.
13. Which of the following detects support for the method of the form?
a) input formtarget
b) input formmethod
c) input formenctype
d) input formaction
View Answer
Answer: b
Explanation: input formmethod detects support for formmethod attribute, input formtarget
detects for formtarget attribute on forms, input formenctyp detects for the support of
formenctype attribute, it overrides form enctype attribute, input formactin detects for the
support of formaction attribute.
14. Which of the following check support for non-alpha, lossy webp?
a) Webp
b) Webp Lossless
c) Webp Animation
d) Webp Alpha
View Answer
Answer: b
Explanation: Webp Lossless detects for lossless webp, non-alpha webp support. Webp
tests for all forms of webp support like alpha, lossy, animated, lossless etc. Webp Animation
detects for the support of animation in webp, Webp Alpha detects the support of transparent
webp.
15. Which of the following detects for the support of size attribute of an image?
a) JPEG 2000
b) JPEG XR
c) Image crossOrigin
d) Sizes
View Answer
Answer: d
1. URL is ___________
a) web address
b) source code
c) user’s address
d) an attribute
View Answer
Answer: a
Explanation: URL is the second name of a web address. It is composed of IP (Internet
Protocol) address or words. Its full form is Uniform Resource Locators. Generally entering
name while surfing is easy as numbers are hard to remember.
4. ASCII is _____________
a) 6-bit character set
b) 7-bit character set
c) 9-bit character set
d) 3-bit character set
View Answer
Answer: b
Explanation: ASCII consists 7-bit character set which has 128 characters. There are
numbers 0-9, upper and lower case letters from A-Z, and also include special characters.
Including modern computers, internet these characters are used in HTML also.
4. Which feature is not used when SQL features are not being supported?
a) BEGIN
b) END
c) COMMIT
d) ROLLBACK
View Answer
Answer: b
Explanation: When SQL feature is not supported then we use COMMIT, BEGIN,
ROLLBACK SQL features and are marked as bogus. User agent uses the statements that
contain these three words in case of failure of the support of SQL features.
11. Which of the error is raised when the quantity of data is too much?
a) TOO_LARGE_ERR
b) UNKNOWN_ERR
c) TIMEOUT_ERR
d) QUOTA_ERR
View Answer
Answer: a
Explanation: When the quantity of the data returned from the database is very large then
TOO_LARGE_ERR is invoked. To minimize the data we can use SQL “LIMIT” i.e. modifier
to reduce the size of the resultant set.
5. Which is the best platform for working with the individual image?
a) SpriteMe
b) Fireworks CS6
c) Lemonade
d) Compass
View Answer
Answer: a
Explanation: SpriteMe is brilliant sprite sheet viewer and generator. It is available at a free
of cost. We can design our website using individual images. It is very simple to use. By
using SpriteMe we can also view current sprite sheets that are already present on a
website.
13. Which process is used for the creation of the end result?
a) render()
b) compile()
c) eval(x)
d) encodeURI()
View Answer
Answer: a
14. Which of the following is not the layer of the OSI Model?
a) Transport Layer
b) Network Layer
c) Session Layer
d) Atomic Layer
View Answer
Answer: d
Explanation: OSI model stands for Open Systems Interconnection model. It is commonly
used for representing various parts of network traffic. There are seven layers in the OSI
model, Physical Layer, Data Link layer, Network Layer, Transport Layer, Session Layer,
Presentation Layer and Application Layer.
10. Which command controls the maximum number of tables that the cache can hold?
a) table_open_cache
b) table_definition_cache
c) open_files_limit
d) read_buffer_size
View Answer
Answer: a
Explanation: The option for table cache is table_open_cache. It controls the maximum
number of tables that the cache can hold, we set the variable equal to the total number of
table, table_definition_cache is the lightweight partner to table cache.
4. Which of the following is not the element associated with HTML table layout?
a) size
b) spanning
c) alignment
d) color
View Answer
Answer: d
Explanation: There are three elements in HTML table layout i.e. size, spanning and
alignment. Layout type can be achieved by setting Rows elements layout attribute to Fixed
or Auto. Auto attribute relies on browser compatibility whereas fixed layout relies on
developer specification.
<thead> tag contains the group of header. <tr> is used to indicate start of every row i.e. it
stands for table row. The header information is present in <th> tag.
13. Which of the following is not the value for rules attribute?
a) vsides
b) rows
c) all
d) groups
View Answer
Answer: a
Explanation: The rules which will appear between cells of the table is specified by this
attribute. It can take the values groups, none, rows, all and cols. None is the default value,
rows are for appearance between rows only and cols is for columns only.
14. Which of the following is not the value for align attribute?
a) justify
b) char
c) middle
d) left
View Answer
Answer: c
Explanation: align attribute is the alignment of data and for justification of text in the cell. It
can take the values left, right, justify, center, char. Justify is for double justifying the text,
char is for aligning text around a particular character.
When one wants to write a message in console, console.log() is used. The window.alert()
alerts message in box on window.
advertisement
This is the first line. </pre>. A text which has been inserted into a document is defined by a <ins>..
9. Which one of the following is not the value of the target attribute?
a) _blank
b) _top
c) _self
d) _empty
View Answer
Answer: d
Explanation: Where to open linked document is specified by target attribute. It can have the
values _blank, _top, _parent, _self, framename. _blank opens linked document is a new tab
or window. The linked document is opened in the parent frame by _parent. Linked
document is opened in a named frame by framename. Linked document is opened in the
same window by _self.
10. What is the path for an image located in same folder as the current page?
11. File paths are not used for linking in _________
a) JavaScripts
b) PHP
c) Style Sheets
d) Images
View Answer
Answer: b
Explanation: The location of a file in web site’s folder structure is described by file path. File
paths are used for linking to external files like Images, JavaScripts, Web Pages, Style
sheets. The full URL to internet file is an absolute file path.
11. Which property specifies the distance between nearest border edges of marker box and
prinicipal box?
a) marker-offset
b) counter increment
c) list-style
d) list-style-image
View Answer
Answer: a
5. Which one of the following is used for adding Flash in the web page?
a) CSS
b) jQuery
c) PHP
d) JavaScript
View Answer
Answer: d
Explanation: One of the most popular for adding Flash to the web page is using JavaScript.
There is no need to understand this language in depth because there are many scripts
already available that are available to do this.
6. Which one of the following is not used inside the <script> tag in Flash videos?
a) replace
b) location
c) version
d) id
View Answer
Answer: d
Explanation: There are five attributes that can be used inside the <script> tag in Flash
videos namely width, height, version, location and replace. The minimum version of the
Flash player needed to view the movie is specified by version. Width and Height of Flash
movie are specified by width, height. The location of .swf file is specified by location.
7. Which one of the following is not the online video format available?
a) Ogg Theora
b) VHS
c) WebM
d) H264
View Answer
Answer: b
Explanation: Online there are movies available in many formats like Ogg Theora, WebM,
QuickTime, AVI, Flash Video, MPEG, Windows Media etc. There are also some of the
offline formats like DVD, VHS, BlueRay etc.
8. For playing Flash Video you need to convert video into the ___________ format.
a) FLV
b) BlueRay
c) WebM
d) MPEG
View Answer
Answer: a
Explanation: For playing Flash video one must convert the video into FLV format. Flash 6,
the Flash authoring environment comes with Flash Video Encoder to convert the videos into
FLV formats. It also supports H264 format.
4. Which of the following specifies what happens if content overflow an element’s box?
a) overflow
b) overflow-x
c) overflow-y
d) float
View Answer
Answer: a
Explanation: overflow property specifies what happens if content overflows an element’s
box, overflow-x specifies what to do with left/right edges of the content if it overflows the
element’s content area, overflow-y specifies what to do with top/bottom edges of the content
if it overflows the element’s content area.
6. Which property defines in which direction the container wants to stack flex items?
a) flex-flow
b) flex-wrap
c) flex-direction
d) align-content
View Answer
Answer: c
Explanation: flex-direction property defines in which direction the container wants to stack
the flex items, the flex-flow property is shorthand property for setting both flex-direction and
flex-wrap properties. For deciding whether the flexible items should wrap or not, flex-wrap
property is used.
E.g.
<nav>
<ul>
<li><a href="https://www.sanfoundry.com/" class= “dream”>HTML</a> </li>
<li><a href="https://www.sanfoundry.com/">CSS</a> </li>
<li><a href="https://www.sanfoundry.com/">PHP</a> </li>
</ul>
</nav>
Footer typically contains information about author of the section, links to related documents
or copyright data. An introductory content lies in <header>. Contact information of
author/owner of a document can be provided by <address> tag.
7. For grouping together one or more <h1> to <h6> element what element is used?
a) <header>
b) <hgroup>
c) <div>
d) <section>
View Answer
Answer: b
Explanation: For grouping together set of one or more <h1> to <h6> element we use
<hgroup> element. We can group together the primary heading and the subheading. E.g.
<hgroup> <h2> Winter is coming!</h2> <h3>Its too cold</h3> </hgroup>. Grouping of
related content together is done by <section> element. For grouping together related
elements we use <div> element. An introductory content lies in <header>.
1. Which browser was the first that allows CSS rules to be associated with new HTML5
layout elements?
a) Internet Explorer 9
b) Internet Explorer 7
c) Chrome
d) Firefox
View Answer
Answer: a
Explanation: Internet Explorer was the first version that allowed CSS rules to be associated
with new HTML5 layout elements. Older browsers that do not know new HTML5 elements
will by default treat them as inline elements.
8. Which of the following does not use a crawler to find pages for the search result?
a) Bing
b) Backrub
c) Yahoo
d) Google
View Answer
Answer: b
Explanation: Leading search engines like Bing, Google and Yahoo use crawlers for finding
pages for the algorithmic search results. Pages linked from other search engine indexed
pages do not need to be submitted because they are found by default.
Meta elements like noindex and follow can also be used to stop duplicate content.
9. Which one of the following is not the default control in google maps?
a) Pan
b) Street view
c) MapType
d) Climate map
View Answer
Answer: d
Explanation: Google map has a default control set namely Pan, Zoom, Street view,
MapType, Rotate, Overview map, scale. A slider or “+/-” buttons for controlling zoom level
of the map. For panning the map we use pan control.
13. Which of the following type will support 45 degree perspective view?
a) Terrain
b) Hybrid
c) Roadmap
d) Climate map
View Answer
Answer: b
Explanation: Satellite and hybrid type of map support 45 degree perspective imagery view
for specified locations. The map will add a compass wheel around Pan control, it allows to
rotate the image. There is a toggle control to display 45 degree perspective view.
14. Which of the following method will return DOM object that contains map?
a) getCenter()
b) getProjection()
c) getDiv()
d) gettilt()
View Answer
Answer: c
Explanation: getDiv() method will return DOM object that contains map. Its return type is
node. getCenter() will return lng/lat of center of the map. getTilt() method will return angle of
incidence for aerial imagery in degrees. Current position is returned when getProjection()
event is fired up.
15. Which one of the following will set the viewport to contain given bounds?
a) fitBounds()
b) getBounds()
c) getHeading()
d) panTo()
View Answer
Answer: a
2. Which of the following event does not take a MouseEvent argument in Map()?
a) dbclick
b) drag
c) click
d) mouseover
View Answer
Answer: b
Explanation: There are various events of Map() that takes MouseEvent as an argument.
Some of them are dbclick, click, mouseout, mousemove, mouseover, rightclick. When a
user clicks the map click event is fired and on double clicking on the map dbclick event is
fired.
3. Which of the following event will be fired when a user drags the map?
a) dragend
b) drag
c) dragstart
d) idle
View Answer
Answer: b
Explanation: The drag event will be fired repeatedly while the user drags the map. When the
user stops dragging the map dragend event will be fired, dragstart event will be fired when a
user starts dragging the map.
advertisement
4. Which of the following event will be called when user’s mouse exits map container?
a) mouseout
b) mouseover
c) mousemove
d) resize
View Answer
Answer: a
Explanation: mouseout event will be called when user’s mouse exits mouse container,
mouseover event will be called when the user’s mouse enters map container, mousemove
event will be called when user’s mouse moves over the map.
8. Which of the following will provide options for rendering overview map control?
a) MapTypeControlStyle
b) OverviewMapControlOptions
c) MapTypeControlOptions
d) PanControlOptions
View Answer
Answer: b
Explanation: OverviewMapControlOptions will provide options for rendering of overview
map control, MapTypeControlStyle will specify kind of map control to display.
MapTypeControlOptions holds options to modify a control. Options for rendering pan control
is given by PanControlOptions.
4. Which function will be called when the last instance of a plug-in is deleted?
a) NPP_Destroy
b) NP_Initialize
c) NPP_New
d) NP_Shutdown
View Answer
Answer: d
Explanation: When the last instance of a plug-in is deleted Gecko calls the function
NP_Shutdown. The plug-in code is unloaded from memory. Plug-ins consume no resources
when not loaded, it only consumes a little disk space.
1. Which of the following is not a transmission mode that plug-in can select?
a) File mode
b) Random-access mode
c) Normal mode
d) Complex mode
View Answer
Answer: d
Explanation: There are three transmission modes that plug-in can select. In normal mode
browser sends stream data sequentially to plug-in, in Random-access mode browser allows
a plug-in to request specific ranges of bytes from anywhere in the stream. In File, mode
browser saves data to a local file in cache and passes the file path to plug-in.
2. Which method is used for sending data to URL from memory buffer?
a) NPN_PostURL
b) NPN_GetURLNotify
c) NPN_GetURL
d) NPN_PostURLNotify
View Answer
Answer: a
Explanation: For sending data to URL from file or a memory buffer we used NPN_PostURL.
The result obtains from a server can also be sent to a particular browser window or frame
for display, or delivered to a plug-in instance in the new stream.
3. Which of the following request is used for the browser to load a URL?
a) NPN_GetURL
b) NPN_PostURL
c) NPN_PostURLNotify
d) NPN_GetURLNotify
View Answer
Answer: a
Explanation: NPN_GetURL is a request for the browser to load a URL into a particular
frame for display or browser window, or for delivering data of that URL to the plug-in
instance in a new stream. NPN_PostURLNotify function notifies plug-in of a result when an
operation completes.
advertisement
6. Which of the following is called after plug-in is initialized to get scripting interface?
a) NPP_GetValue
b) NP_GetValue
c) NP_GetMIMEDescription
d) NP_Initialize
View Answer
Answer: a
Explanation: After the plug-in is initialized to get scripting interface NPP_GetValue is called.
NP_GetValue is called during initialization to retrieve plug-in’s description and name, that
will appear in navigator.plugins DOM object and is used to populate about:plugins.
10. Which of the following method is not associated to handling the memory
________________
a) NPN_MemFlush
b) NPN_MemAlloc
c) NPN_MemFree
d) NPP_HandleEvent
View Answer
Answer: d
7. Which of the following specifies relationship between current document and external
resource?
a) <meta>
b) <style>
c) <link>
d) <title>
View Answer
Answer: c
Explanation: Relationship between current document and external resource is specified by
<link> element. The possible uses for this element include defining relational framework for
navigation. It is mostly used to link to style sheets. <title> element specifies title of the
document. Metadata about HTML document is provided by <meta> element. <style>
element specifies style information about the HTML document.
11. Which element denotes that the text is a short fragment of computer code?
a) <code>
b) <data>
c) <cite>
d) <dfn>
View Answer
Answer: a
Explanation: Title of work is defined by <cite> tag. The <code> element displays its contents
styles in a fashion intended to indicate that text is a short fragment of computer code. The
content text is displayed using user agent’s default monospace font by default. <data>
element links content with machine readable translation. Defining instance of a term in
HTML is represented by <dfn> element.
13. Which element prevents the text from automatically wrapping across multiple lines?
a) <em>
b) <kbd>
c) <mark>
d) <nobr>
View Answer
Answer: d
Explanation: <em> is same like <i></i>. It is emphasized text. <kbd> element is HTML
Keyboard Input Element. <mark> element is for highlighting the text/paragraph. <nobr> is
non-standard obsolete HTML element. This element prevents the text it contains from
automatically wrapping across multiple lines. Resulting in the user having to scroll
horizontally to see entire width of the text.
14. Which element represents a scalar value within the given range?
a) <option>
b) <meter>
c) <label>
d) <input>
View Answer
Answer: b
Explanation: <option> represent item contained in <select> element. <meter> element in
HTML represents either a scalar value within a known range or a factorial value. It includes
global attributes like min, max, value, optimum, low, high, form etc. <label> specifies a
caption for item in user interface. <input> element is used to take user input from user.
3. Which element represents group of commands that user can activate or perform?
a) <menuitem>
b) <menu>
c) <summary>
d) <details>
View Answer
Answer: b
Explanation: <menuitem> represents a command which helps user to pop up through
menu. <menu> element in HTML represents group of commands that user can perform or
activate. This include list menu as well as context menus. List menus appear across top of a
screen and context menus might appear underneath a button after it has been clicked.
<summary> element is known as Disclosure Summary element. <details> elment provides
information that user can view or hide as per own wish.
advertisement
9. Which element sets default font face, size and color for other elements?
a) <applet>
b) <basefont>
c) <big>
d) <acronym>
View Answer
Answer: b
Explanation: <applet> embeds java applet in web document. <basefont> is obsolete HTML
element. It sets default font face, size, and color for other elements which are descended
from its parent element. Instead of using this element we can use font, font-size, font-family
and color to change font configuration for an element. <acronym> element which has been
removed from HTML5 indicates sequence of characters. <big> element increase the font
size.
13. Which element puts a text field in a page for querying document?
a) <keygen>
b) <isiindex>
c) <dir>
d) <command>
View Answer
Answer: b
Explanation: An element which exists to facilitate generation of key material is <keygen>.
<isindex> is an obsolete HTML element. It puts a text field in a page for querying the
document. It is deprecated as of HTML 4.1, because same behavior can be achieved with
HTML form. All major browsers have now removed <isindex>. <dir> contains list of
directories. Those commands that user can invoke are represented by <command>.
4. Which attribute specify a column name from the data source object?
a) datafld
b) codebase
c) hspace
d) datasrc
View Answer
Answer: a
Explanation: datafld attribute is supported by Internet Explorer 4 and its higher versions. It
specifies column name from the data source object that supplies bound data. This attribute
may be used to specify various <param> elements passed to Java applet. Codebase gives
absolute or relative URL of directory. In applet, hspace provides horizontal space on both of
sides. HTML datasrc attribute used for data binding.
4. Which button let us move the map to the current position of the device?
a) currentPositionBtn
b) enableHighAccuracy
c) timeout
d) maximumAge
View Answer
Answer: a
Explanation: The geolocation HTML includes a currentPositionBtn which is used to move
the map to the current position of the device, there are 3 inputs to let the user choose the
geolocation options enableHighAccuracy, timeout, and maximumAge.
11. Which of the following specifies the time when location information was retrieved?
a) timestamp
b) cords.speed
c) cords.heading
d) cords.altitudeAccuracy
View Answer
Answer: a
Explanation: timestamp specifies the time when location information was retrieved and the
position object created. cords. speed specifies device’s current ground speed in meters per
second, cords.heading specifies the device’s current direction of movement in degrees.
15. Which of the following specifies the expiry time for cached location information?
a) maximumAge
b) timeout
c) enableHighAccuracy
d) position_unavailable
View Answer
Answer: a
12. Which property specifies the path to the project when running in web server?
a) http_path
b) images_dir
c) css_dir
d) sass_dir
View Answer
Answer: a
Explanation: http_path specifies a path to the project when running on a web server. It is set
to/by default., so the path output will begin with /. E.g. background-image:
url(“/image/hj.png”). Folder name for all the images to be stored is specified by images_dir.
css_dir specifies folder name for CSS style sheets. sass_dir gives folder name for the sass
or SCSS style sheet to be stored.
13. Which property specifies the folder name where CSS style sheets should be saved?
a) relative_assets
b) sass_dir
c) css_dir
d) javascript_dir
View Answer
Answer: c
Explanation: sass_dir gives folder name for the sass or SCSS style sheet to be stored.
css_dir property specifies the folder name where CSS style sheets should be saved. We
can change css_dir value to something like css or styles, but we should also change the
folder name in the working directory to the one that matches the change. A folder name
where javascript file are stored is given by javascript_dir. The output path in compiled CSS
is given by relative_assets.
14. Which of the following specifies compiles CSS output?
a) relative_assets
b) output_style
c) line_comments
d) sass_dir
View Answer
Answer: b
Explanation: The output path in compiled CSS is given by relative_assets. The output_style
property specifies compiled CSS output. The accepted values for this property are
:nested, :expanded, :compressed or :compact. line_comments specifies whether compass
should generate line number where style sheets rule are defined. sass_dir gives folder
name for the sass or SCSS style sheet to be stored.
3. What should be the set value of the background-size property such that image will fit in
the content area?
a) 100%100%
b) contain
c) cover
d) 100%
View Answer
Answer: a
Explanation: If the background-size property is set to “contain”, the background image will
scale and will try to fit in the content area. Still, the image will keep its aspect ratio i.e. the
proportional relationship between the image’s width and height.
advertisement
4. What should be the set value of background-size property such that image will stretch to
cover entire content area?
a) 100%100%
b) cover
c) contain
d) 100%
View Answer
Answer: a
Explanation: If background-size property is set to “100%100% “ the background image will
stretch to cover the entire content area. E.g. div { width: 100%; height: 300px; background-
image: url(‘img_khj.jpg’); }
5. What should be the set value of background-size property such that image will cover the
entire content area?
a) 100%
b) contain
c) cover
d) 100%100%
View Answer
Answer: c
Explanation: If background-size property is set to “cover”, background image will scale to
cover entire content area. “cover” value keeps the aspect ratio and some part of
background image may be clipped. E.g. div {width: 100%; height: 390px; background-
image: url(‘img_tyu.jpg’); background-size: cover;}
10. Which of the following indicates current page’s location within the navigational
hierarchy?
a) .breadcrumb
b) .btn
c) .active
d) .bg-warning
View Answer
Answer: a
Explanation: .breadcrumb is a pagination. It indicates the current page’s location within a
navigational hierarchy, .btn creates a basic button i.e. gray background and rounded
corners, .bg-warnong adds the yellow background color to an element.
4. Which of the following adds default styles for dropdown menu container?
a) .dropdown-menu
b) .dropdown-toggle
c) .dropdown-menu-right
d) .dropdown
View Answer
Answer: a
Explanation: .dropdown-menu adds default styles for dropdown menu container, .dropdown-
header is used to add headers inside dropdown menu, .dropdown-right right-aligns a
dropdown menu, .dropdown-toggle is used on the button that should hide and show the
dropdown menu.
13. Which of the following is used to align pager buttons to the left side of the page?
a) .previous
b) .prev
c) .pre-scrollable
d) .popover
View Answer
Answer: a
Explanation: .previous class is used to align pager buttons to the left side of the page, .prev
is used in carousels to indicate a “previous” link, .pre-scrollable makes a <pre> element
scrollable, .popover shows popup-box that appears when a user clicks on an element.
14. Which of the following is a container for content inside the panel?
a) .panel-body
b) .panel-collapse
c) .panel-success
d) .panel-footer
View Answer
Answer: a
Explanation: .panel-body is a container for content inside the panel, .panel-collapse is for
the collapsible panel which toggles between hiding and showing panel, .panel-success
shows green panel indicating success, .panel-footer creates a panel footer.
10. Which of the following displays text inside <abbr> in slightly smaller font size:
a) .info
b) .input-group
c) .initialism
d) .in
View Answer
Answer: c
Explanation: .initialism displays text inside <abbr> element in slightly smaller font size,
.input-group is a container to enhance input by adding an icon, text or button in front or
behind it as a “help text”, .info adds light-blue background to table row, indicating a neutral
informative change or action.
14. Which of the following adds plain text next to form label?
a) .form-control-static
b) .form-group
c) .form-inline
d) .form-control
View Answer
Answer: a
Explanation: .form-control-static adds plain text next to form label within a horizontal form,
.form-group is a container for form input and label, .form-inline makes a <form> left-aligned
with inline-block controls, .form-control is used on input, textarea, and select elements to
span the entire width of the page and make them responsive.
1. Which of the following removes the default list-style and left margin on list items?
a) .list-unstyled
b) .blockquote-reverse
c) .list-inline
d) .initialism
View Answer
Answer: a
Explanation: .list-unstyled removes default list-style and left margin on list items, it works on
both <ul> and <ol>, this class only applies to immediate children list items to remove the
default list-style from any nested lists, can be applied to any listed lists as well. .initialism
displays text inside <abbr> tag. All items in a single line is displayed by .list-inline.
2. What lines up the terms and descriptions in <dl> element side by side?
a) .list-inline
b) .dl-horizontal
c) .list-unstyled
d) .initialism
View Answer
Answer: b
Explanation: .dl-horizontal lines up the terms and descriptions in <dl> element side-by-side,
it starts off like default <dl>s, but when browser window expands it will line up side-by-
side. .list-unstyled removes default list-style and left margin on list items. .initialism displays
text inside <abbr> tag.
9. Which of the following removes left, top and right borders from navbar?
a) .navbar-toggle
b) .navbar-right
c) .navbar-static-top
d) .navabr-nav
View Answer
Answer: c
Explanation: .navbar-nav is used on <ul> container that contains list items with links inside a
navigation bar. .navbar-right aligns nav links, forms, buttons or text in navbar to the right.
.navbar-static-top removes left, top and right borders (rounded corners) from navbar, default
navbar has a grey border and 4px border-radius by default, .navbar-toggle styles button that
should open navbar on small screens.
3. Which of the following occurs after fixed positioned is added to the element?
a) affix.bs.affix
b) affixed.bs.affix
c) affix-top.bs.affix
d) affixed-top.bs.affix
View Answer
Answer: b
Explanation: affixed.bs.affix occurs after fixed positioning is added to the element e.g.
after .affix-top class is replaced with .affix class, affix-bs.affix occurs before fixed positioning
is added to the element e.g. when .affix-top class is to be replaced with .affix class. Affix-
top-bs.affix occurs before top ekement return to its original place. Affixed-top-bs.affix occurs
before top ekement return to its original place.
advertisement
15. Which of the following method will hide and destroy tooltip?
a) .tooltip(“hide”)
b) .tooltip(“toggle”)
c) .tooltip(“destroy”)
d) .tooltip(options)
View Answer
Answer: c
9. Which one of the following is not the default control in google maps?
a) Pan
b) Street view
c) MapType
d) Climate map
View Answer
Answer: d
Explanation: Google map has a default control set namely Pan, Zoom, Street view,
MapType, Rotate, Overview map, scale. A slider or “+/-” buttons for controlling zoom level
of the map. For panning the map we use pan control.
13. Which of the following type will support 45 degree perspective view?
a) Terrain
b) Hybrid
c) Roadmap
d) Climate map
View Answer
Answer: b
Explanation: Satellite and hybrid type of map support 45 degree perspective imagery view
for specified locations. The map will add a compass wheel around Pan control, it allows to
rotate the image. There is a toggle control to display 45 degree perspective view.
14. Which of the following method will return DOM object that contains map?
a) getCenter()
b) getProjection()
c) getDiv()
d) gettilt()
View Answer
Answer: c
Explanation: getDiv() method will return DOM object that contains map. Its return type is
node. getCenter() will return lng/lat of center of the map. getTilt() method will return angle of
incidence for aerial imagery in degrees. Current position is returned when getProjection()
event is fired up.
15. Which one of the following will set the viewport to contain given bounds?
a) fitBounds()
b) getBounds()
c) getHeading()
d) panTo()
View Answer
Answer: a
4. Which of the following attributes is used to specify elements to bind style rules to?
a) id
b) class
c) tag
d) all of the mentioned
View Answer
Answer: d
Explanation: In CSS, styling elements can be done by id, class and tag attribute.
5. Which selector is used to specify a rule to bind a particular unique element?
a) id
b) class
c) tag
d) both class and tag
View Answer
Answer: a
Explanation: For binding a particular unique element, id selectors are used. While for group
of elements, class selector can be used.
9. __________ has introduced text, list, box, margin, border, color, and background
properties.
a) css
b) html
c) ajax
d) php
View Answer
Answer: a
Explanation: CSS is a style sheet language which stands for Cascading Style Sheet. CSS
has introduced text, list, box, margin, border, color, and background properties.
10. Is it the best way to include H1 heading only one time on the web page.
a) True
b) False
View Answer
Answer: a
1. Which of the following element is used by the filter property to blur the images?
a) opaque()
b) scatter()
c) blur()
d) all of the mentioned
View Answer
Answer: c
Explanation: Blurs an element, for use by the filter property. Accepts a distance
measurement within which pixels are randomly scattered. A value of 0 leaves the image as
is.
2. Which of the following function adjust the brightness of an element’s color, for use by the
filter property?
a) contrast()
b) dark()
c) light()
d) brightness()
View Answer
Answer: d
Explanation: A value of 100% or decimal value of 1 leaves the image as is, while 0
produces black. Increasing the value from 1 or 100% brightens pixels from their original
values.
3. Which of the following function adjusts the difference between light and dark values, for
use by the filter property?
a) contrast()
b) dark()
c) light()
d) brightness()
View Answer
Answer: a
Explanation: A value of 100% or a decimal value of 1 leaves the image as is, while 0 results
in black. Increasing the value past 1 or 100% produces more dramatically stratified areas of
light and dark.
advertisement
4. Which of the following function with filter property to create your own sophisticated effects
on DOM elements?
a) create()
b) DOM()
c) custom()
d) none of the mentioned
View Answer
Answer: c
Explanation: None.
5. Which of the following function converts an element’s color to a shade of gray, for use by
the filter property?
a) shade()
b) grayscale()
c) black()
d) brightness()
View Answer
Answer: b
Explanation: A decimal value between 0 and 1 or percentage up to 100% controls the
extent of the gray effect.
6. Which of the following function flips an element’s colors, for use by the filter property?
a) image()
b) flip()
c) invert()
d) contrast()
View Answer
Answer: c
Explanation: A decimal value between 0 and 1 or percentage up to 100% controls the
extent of the color-negative effect, with 0.5 or 50% producing gray.
7. Which of the following function applies a saturation effect to an element’s color, making it
appear more or less vivid, for use by the filter property?
a) color()
b) saturation()
c) saturate()
d) none of the mentioned
View Answer
Answer: b
Explanation: A decimal value of 1 or percentage of 100% keeps the image as is, while
increasing the amount produces more dramatically stratified hues.
10. Which of the following function apply a sepia tinge to an element’s color, typical of old
photographs, for use by the filter property?
a) grayscale()
b) sepia()
c) contrast()
d) brightness()
View Answer
Answer: b
1. Which of the following value is supposed to be a slightly bolder weight that standard bold
in font attribute?
a) empasize
b) light
c) lighter
d) dark
View Answer
Answer: d
Explanation: Self-explainatory.
2. Which of the following property allows contextual adjustment of inter-glyph spacing, i.e.
the spaces between the characters in text?
a) font-style
b) font-family
c) font-kerning
d) font-variant
View Answer
Answer: c
Explanation: Self-explainatory.
4. Which of the following value specifies whether the user agent is allowed to synthesize
bold or oblique font faces when a font family lacks bold or italic faces?
a) font-weight
b) font-synthesis
c) font-kerning
d) font-variant
View Answer
Answer: b
Explanation: Self-explainatory.
5. Which of the following selects a normal, or small-caps face from a font family?
a) font-weight
b) font-synthesis
c) font-kerning
d) font-variant
View Answer
Answer: d
Explanation: Self-explainatory.
7. Which of the following property adjusts the font-size of the fallback fonts defined with
font-family, so that the x-height is the same no matter what font is used?
a) default
b) font-size-fallback
c) font-adjust
d) font-size-adjust
View Answer
Answer: d
Explanation: Self-explainatory.
8. Which of the following Allows you to expand or condense the widths for a normal,
condensed, or expanded font face?
a) font-style
b) font-stretch
c) font-expand
d) none of the mentioned
View Answer
Answer: d
Explanation: Self-explainatory.
9. Which of the following font-size-adjust is value used in calculating the size of the fallback
fonts?
a) auto
b) number
c) count
d) none
View Answer
Answer: b
Explanation: Self-explainatory.
10. “font-style comes first than font-weight in font attribute”.State true or false.
a) True
b) False
View Answer
Answer: b
6. Which of the following CSS property is used to give a line over the text?
a) text-decoration: underline
b) text-decoration: overline
c) text-decoration: line-through
d) text-decoration: none
View Answer
Answer: b
Explanation: Text-decoration is a CSS property used to decorate the text. The text-
decoration property takes many values such as overline, underline, line-through, none,
inherit, etc. Overline gives a line over the text. Underline value is used to add line under the
text. None value defines a normal text. When one wants to give a line through the text, line-
through value for text-property can be used.
8. _________ first became a Candidate Recommendation on February 25, 2004, but it was
reverted to a Working Draft on June 13, 2005 for further review.
a) CSS level 1
b) CSS level 2
c) CSS level 3
d) CSS level 2.1
View Answer
Answer: d
Explanation: CSS level 2 revision 1, often referred to as “CSS 2.1”, fixes errors in CSS 2,
removes poorly supported or not fully interoperable features and adds already implemented
browser extensions to the specification. To comply with the W3C Process for standardizing
technical specifications, CSS 2.1 went back and forth between Working Draft status and
Candidate Recommendation status for many years. CSS 2.1 first became a Candidate
Recommendation on February 25, 2004, but it was reverted to a Working Draft on June 13,
2005 for further review.
10. Unlike CSS 2, which is a large single specification defining various features?
a) CSS level 1
b) CSS level 2
c) CSS level 3
d) CSS level 2.1
View Answer
Answer: c
1. ___________ describes CSS properties to manipulate the position of “ruby”, which are
small annotations on top of or next to words, especially common in Chinese and Japanese.
a) align
b) ruby
c) lang
d) text-align
View Answer
Answer: b
Explanation: Align is used to align the content either left, right or center. Ruby describes
CSS properties to manipulate the position of “ruby”, which are small annotations on top of or
next to words, especially common in Chinese and Japanese. They are often used to give
the pronunciation or meaning of difficult ideograms. Text-align is for aligning the text either
left, right or in center.
2. ___________ has a grammar but unlike traditional (X)HTML it is not defined with a
document type definition.
a) CSS 1
b) CSS 2
c) CSS 2.1
d) CSS 3
View Answer
Answer: c
Explanation: CSS 2.1 has a grammar (www.w3.org/TR/CSS21/grammar.html) but unlike
traditional (X)HTML it is not defined with a document type definition. Instead the CSS
specification is a combination of prose and a grammar that could be used to build a simple
parser.
advertisement
h1 {color: "green";}
6. With, which tag you write the style rules directly within the document found
within the head of the document.
a) <script>
b) <php>
c) <style>
d) <css>
View Answer
Answer: c
Explanation: In <style></style> tag we write the style rules directly within the document in
the head section of the document. <script></script> tag is used to add javascript in the
document.
7. What does screen media type is used for?
a) For use with all devices
b) For use with handheld devices
c) For use with computer screens
d) For use with television-type devices
View Answer
Answer: c
Explanation: In CSS, media types are used for the compatibility of devices. There are four
types of nedia types i.e all, print, screen and speech. Out of which screen media type is
used for computer screens, tablets, smart-phones, etc.
8. For Inline Style, we don’t need to reapply style information throughout the document and
outside documents.
a) True
b) False
View Answer
Answer: b
Explanation: In inline style, properties are confined with a particular element to which it is
applied. It won’t be applied to other element of the same type. We need to reapply style
information throughout the document whenever it is necessary.
1. Which of the following tag is used to linked information should be placed inside?
a) <head>
b) <html>
c) <div>
d) <body>
View Answer
Answer: a
Explanation: Linked information regarding CSS like external CSS document information is
always placed in <head> tag. <body> tag contains the body of the document.
3. The ________________ directive allows style sheets to be grouped and joined together,
though some might wonder what the value of this function is given what linked styles
provide.
a) <head>
b) <style>
c) <script>
d) @import
View Answer
Answer: d
Explanation: Within embedded <style> blocks, properties can be imported from an external
file and expanded in place, similar to a macro. Importing can be used to include multiple
style sheets. An imported style is defined within a <style> tag using @import followed
optionally by a type value and a URL for the style sheet. <style> & <script> tag conatins
CSS and Javascript content respectively. The metadata content is present in <head> tag.
advertisement
7. Which of the following property sets a variation of the specified or default font family?
a) height
b) font-weight
c) default
d) font-variant
View Answer
Answer: d
Explanation: Syntax:
font-variant: normal | small-caps | inherit
The small-caps value sets text in smaller-size all capitals. The normal value would be used
to override any inherited font-variant value. Font-weight is for increasing/decreasing weight
of font. It takes values like normal, bold, lighter, and bolder.
list-style-image add graphical image to a list item. List-style sets all the properties for a list.
10. Which of the following property sets the amount of spacing between letters?
a) space
b) line-height
c) letter-spacing
d) letter-space
View Answer
Answer: c
1. Which of the following CSS3 Color Feature can be used as a macro for whatever the
current color is?
a) CurrentColor keyword
b) HSLa Color
c) HSL Color
d) RGB Color
View Answer
Answer: a
Explanation: This is useful if you want to dynamically change one color and have other
related colors change.
2. Which of the following CSS3 Color Feature like RGB color but adds an alpha channel
value to specify the opacity of the color?
a) RGB
b) RGBa
c) RGBaplha
d) AlphaRGB
View Answer
Answer: b
Explanation: An RGBa is specified via a function style rgba(r,g,b,a) value, where colors r, g,
and b are specified as a decimal value from 0 to 255 or a percentage from 0 to 100%, and
the alpha channel value for defining opacity is a number between 0 (fully transparent) and 1
(fully opaque). Values outside this range will be rounded up or down to fit the closest value.
3. Which of the following Color Format is a CSS’s six-digit hexadecimal format is the same
as color defined in (X)HTML?
a) 6-Hex Color
b) 3-Hex Color
c) RGBS
d) RGBa
View Answer
Answer: a
Explanation: The format specifies color as #rrggbb, where rr is the amount of red, gg the
amount of green, and bb the amount of blue, all specified in a hexadecimal value ranging
from 00 to FF.
advertisement
4. Which of the following Color Format is a CSS2 introduced named color keywords which
allows Web page colors to be matched to an operating system’s color use?
a) HSLa Color
b) Commonly defined named colors
c) System Color Names
d) Specificationdefined named colors
View Answer
Answer: c
Explanation: None.
5. Which of the following Color Format are a 17 defined colors under CSS 2.1?
a) HSLa Color
b) Commonly defined named colors
c) System Color Names
d) Specificationdefined named colors
View Answer
Answer: d
Explanation:
maroon (#800000) red (#ff0000)
orange (#ffA500) yellow (#ffff00)
olive (#808000) purple (#800080)
fuchsia (#ff00ff ) white (#ffffff)
lime (#00ff00) green (#008000)
navy (#000080) blue (#0000ff)
aqua (#00ffff) teal (#008080)
black (#000000) silver (#c0c0c0)
gray (#808080)
Other color keywords may be commonly used but are ad hoc in their definition.
6. Which of the following Color Format is a CSS colors can also be defined using the
keyword rgb, followed by three numbers between 0 and 255, contained in parentheses and
separated by commas, with no spaces between them?
a) RGB Color
b) RGBa Color
c) HSL Color
d) HSLa Color
View Answer
Answer: a
Explanation: RGB color values can also be defined using percentages. The format is the
same, except that the numbers are replaced by percentage values between 0% and 100%.
7. Which of the following Color Format is a CSS3 HSL value with a fourth value to set the
alpha channel value for the color to define the opacity of the element?
a) RGB Color
b) RGBa Color
c) HSL Color
d) HSLa Color
View Answer
Answer: d
Explanation: None.
8. Which of the following Selector selects an element if it’s the only child of its parent with its
type?
a) @media
b) :target
c) ::selection
d) :only-of-type
View Answer
Answer: d
Explanation: None.
9. Which of the following Selector same as :firstline; changed under CSS3 to make
pseudoelements obvious?
a) :first-letter
b) :last-child
c) :first-line
d) ::first-line
View Answer
Answer: d
Explanation: None.
10. What does HSL stands for?
a) Hue Specified Lightness
b) Hue Spot Lightness
c) Hue Saturation Lightness
d) None of the mentioned
View Answer
Answer: c
1. Which of the following is not an Absolute Unit?
a) px
b) em
c) pt
d) mm
View Answer
Answer: b
Explanation: em is a Relative Unit
3. Which of the following property sets in a shorthand form any or all background
properties?
a) color
b) wrap
c) background
d) all of the mentioned
View Answer
Answer:
Explanation:
advertisement
4. Which of the following Color Format can also be defined using the keyword rgb, followed
by three numbers between 0 and 255, contained in parentheses and separated by commas,
with no spaces between them?
a) RGB Color
b) RGBa Color
c) HSL Color
d) HSLa Color
View Answer
Answer: a
Explanation:
Example: p {color:rgb(0%,10%,50%);}
6. Which of the following element is used to specify multiple media resources for media
elements like audio and video?
a) <source>
b) <link>
c) <script>
d) <src>
View Answer
Answer: a
Explanation: Self-explainatory.
7. Which of the following Protocol enables a hyperlink to access a file on the local file
system?
a) https
b) ftp
c) file
d) telnet
View Answer
Answer: c
Explanation: Self-explainatory.
8. Which of the following element is used for linking a External Files to the html page?
a) <script>
b) <style>
c) <link>
d) all of the above
View Answer
Answer: c
Explanation: Self-explainatory.
9. Which of the following attribute specifies the URL of the linked resource?
a) src
b) link
c) rel
d) href
View Answer
Answer: d
Explanation: href attribute specifies the URL of the linked resource. A URL might be
absolute or relative.
10. Which of the following color has this value #ff0000?
a) blue
b) green
c) red
d) yellow
View Answer
Answer: c
1. Which of the following CSS property defines the different properties of all four sides of an
element’s border in a single declaration?
a) border
b) padding
c) border-collapse
d) border-width
View Answer
Answer: d
Explanation: The border-width property sets the width of an element’s four borders. This
property can have from one to four values.
2. Identify the CSS property defining bottom-left corner shape of the border?
a) border-radius
b) border-corner-radius
c) border-bottom-left-radius
d) border-left-radius
View Answer
Answer: c
Explanation: CSS3 border-radius property allows you can give any element “rounded
corners”.
3. Select the CSS property that sets the width of an element’s bottom border?
a) border-width
b) border-bottom
c) border-width-down
d) border-bottom-width
View Answer
Answer: d
Explanation: The border-bottom-width CSS property sets the width of the bottom border of a
box.
advertisement
4. Which of the following CSS property border-color property sets the color of an element’s
four borders?
a) border-background
b) border-background-color
c) border-color
d) all of the mentioned
View Answer
Answer: c
Explanation: The border-color property sets the color of an element’s four borders. This
property can have from one to four values.
5. Choose the CSS property that can be used for collapsing the borders between table
cells?
a) border
b) collapse-border
c) border-collapse
d) border-cell
View Answer
Answer: c
Explanation: The border-collapse property sets whether the table borders are collapsed into
a single border or detached as in standard HTML.
6. Which CSS property can be used to set the image as border instead of the border style?
a) background-image
b) border-image
c) background-image-source
d) border-image-source
View Answer
Answer: d
Explanation: The border-image-source property specifies the path to the image to be used
as a border (instead of the normal border around an element).
9. Which of the following specifies the distance between the borders of adjacent cells?
a) border-spacing-cell
b) border-width-spacing
c) border-spacing
d) cell-spacing
View Answer
Answer: c
Explanation: The border-spacing property sets the distance between the borders of
adjacent cells (only for the “separated borders” model).
10. Which of the following property defines the border-width, border-style and border-color
of an element’s top border in a single declaration?
a) border
b) border-top
c) border-top-corner
d) border-top-style
View Answer
Answer: b
1. Which of the following CSS property is used to set the text formatting?
a) font
b) font-style
c) text-decoration
d) all of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
2. Which of the following sets the color of any text decoration, such as underlines, overlines,
and strike throughs?
a) text-font
b) text-format
c) text-color
d) text-decoration-color
View Answer
Answer: d
Explanation: Self-explainatory.
3. Which of the following sets what kind of line decorations are added to an element, such
as underlines, overlines, etc?
a) text-style
b) text-decoration
c) text-line
d) text-decoration-line
View Answer
Answer: a
Explanation: Self-explainatory.
advertisement
4. Which of the following text-decoration value specifies each line of text has a line above
it?
a) line
b) underline
c) overline
d) blink
View Answer
Answer: c
Explanation: Self-explainatory.
6. Which of the following CSS property determines how overflowed content that is not
displayed is signaled to the users?
a) text-flow
b) text-underflow
c) text-overflow
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
7. Which of the following sets the mode for the overline text decoration, determining
whether the text decoration affects the space characters or not?
a) text-decoration
b) text-mode-overflow
c) text-mode
d) text-overline-mode
View Answer
Answer: b
Explanation: Self-explainatory.
8. Which of the following specifies what parts of an element’s content are skipped over
when applying any text decoration?
a) @font-text
b) font-style
c) text-skip
d) text-decoration-skip
View Answer
Answer: d
Explanation: Self-explainatory.
10. Which of the following property applies one or more drop shadows to the text?
a) text-shadow
b) text-effect
c) text-format
d) text-decoration-shadow
View Answer
Answer: a
1. Which of the following property sets the apparent position (in stereo sound) of the
synthesized voice for spoken media?
a) voice-balance
b) media-balance
c) balance
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
2. Which of the following property allows the author to explicitly set the amount of time it
should take a speech synthesizer to read an element’s content?
a) @media
b) voice
c) voice-duration
d) all of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
3. Which of the following property sets the speaker’s voice used by a speech media agent
to read an element?
a) voice-family
b) voice-check
c) voice-control
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
advertisement
4. Which of the following property determines how much variation in pitch or tone will be
created by the speech synthesize when reading an element?
a) voice-pitch
b) voice-range
c) voice-stress
d) none of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
5. Which of the following property sets the speed at which the voice synthesized by a
speech media agent will read content?
a) voice-volume
b) voice-pitch
c) voice-stress
d) voice-rate
View Answer
Answer: d
Explanation: Self-explainatory.
6. Which of the following property sets pitch or tone (high or low) for the synthesized speech
when reading an element; the pitch may be specified absolutely or relative to the normal
pitch for the voice-family used to read the text?
a) voice-check
b) voice-format
c) voice-pitch
d) voice-volume
View Answer
Answer: c
Explanation: Self-explainatory.
7. Which of the following property sets the volume for spoken content in speech media. It
replaces the deprecated volume property?
a) voice-volume
b) volume
c) !important
d) @media
View Answer
Answer: a
Explanation: Self-explainatory.
1. Which of the following property is used to draw a line around elements outside the
borders?
a) line
b) padding
c) outline
d) border
View Answer
Answer: c
Explanation: Outlines do not take up space, they are drawn above the content.
2. Choose the option that correctly specifies the output of the following CSS.
span {
border: 1px solid red;
outline: green dotted thick;
}
a) All span elements will have a red border and a green dotted outline
b) All span elements will have a green thick border and a red outline
c) All span elements will have an outer red border and inner green dotted border
d) All span elements will have a outer green dotted border and an inner red border
View Answer
Answer: d
Explanation: The border property creates the inner border, while the outline sets the outer
border.
advertisement
6. Which of the following property specifies the look and design of an outline?
a) outline-font
b) outline-style
c) outline-format
d) none of the mentioned
View Answer
Answer: b
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.
div {
border-width:5px;
border-style:dotted solid double dashed;
}
a) Box having dotted top outline, solid right outline, double bottom outline and dashed left
outline
b) Box having dotted top outline, solid left outline, double bottom outline and dashed right
outline
c) Box having dotted bottom outline, solid right outline, double top outline and dashed left
outline
d) Box having dotted bottom outline, solid left outline, double top outline and dashed left
outline
View Answer
Answer: a
Explanation: The shorthand run in clockwise direction.
6. The __________ rule makes it possible to define different style rules for different media
types in the same stylesheet.
a) audio/video
b) sink
c) @media
d) @canvas
View Answer
Answer: c
Explanation:
Example:
@media screen {
p {
font-family: verdana, sans-serif;
font-size: 17px;
}
}
8. ____________ types are mutually exclusive in the sense that a user agent can only
support one media type when rendering a document.
a) tv
b) tty
c) media
d) audio
View Answer
Answer: c
Explanation: Media types are mutually exclusive in the sense that a user agent can only
support one media type when rendering a document. However, user agents may use
different media types on different canvases. For example, a document may (simultaneously)
be shown in ‘screen’ mode on one canvas and ‘print’ mode on another canvas.
9. If an @media/@import rule contains a malformed media type (not an identifier) then the
statement is valid. State true or false.
a) True
b) False
View Answer
Answer: b
Explanation: @media and @import rules with unknown media types (that are nonetheless
valid identifiers) are treated as if the unknown media types are not present. If an
@media/@import rule contains a malformed media type (not an identifier) then the
statement is invalid.
1. Which of the following property defines in a shorthand form the width, style, and
color for the bottom border of an element?
a) border-bottom
b) border-bottom-color
c) border-bottom-all
d) none of the mentioned
View Answer
Answer: a
Explanation:
Syntax: border-bottom: border-width border-style border-color;
2. Which of the following property sets the width of an element’s bottom border?
a) border
b) border-collapse
c) border-bottom-width
d) none of the mentioned
View Answer
Answer: c
Explanation:
advertisement
3. Which of the following property defines whether table cell borders are connected or
separate?
a) border-table
b) border
c) border-collapse
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: border-collapse: collapse | separate | inherit
4. Which of the following property defines the style for the right border of an element?
a) border-spacing
b) border-spacing
c) border-right
d) border-right-style
View Answer
Answer: c
Explanation:
Syntax: border-right-style: dashed | dotted | double
5. Which of the following property defines the color of an element’s top border?
a) border-color
b) border-top
c) border-top-color-webkit
d) border-top-color
View Answer
Answer: d
Explanation:
Syntax: border-top-color: color | transparent | inherit
6. Which of the following property sets the width of an element’s complete border?
a) border-width
b) width
c) border-depth
d) none of the mentioned
View Answer
Answer: a
Explanation:
Syntax: border-width: width
7. Which of the following property defines the visual style of up to four different sides of a
border?
a) border-style
b) border
c) border-top
d) none of the mentioned
View Answer
Answer: a
Explanation: Syntax:
border-style: style
8. Which of the following defines in a shorthand form the width, style, and color for the top
border of an element?
a) border-up
b) border-bottom
c) border-style
d) none of the mentioned
View Answer
Answer: d
Explanation:
Syntax: border-top: border-width border-style border-color;
9. Which of the following property defines the y (vertical) coordinate for a positioned
element, relative to the bottom of the enclosing object or browser window?
a) border
b) bottom
c) position
d) none of the mentioned
View Answer
Answer: b
Explanation:
Syntax: bottom: length | percentage | auto | inherit
10. Which of the following property specifies the placement of an element in relation to
floating objects?
a) clear
b) color
c) space
d) none of the mentioned
View Answer
Answer: a
advertisement
2. Which of the following property defines the offset from an element’s border and its
outline?
a) outline-border
b) outline-offset
c) outline-radius
d) none of the mentioned
View Answer
Answer: b
Explanation:
Syntax: outline-offset: length | inherit
3. Which of the following property allows a marquee to be used in the case of a text
overflow?
a) overflow-style
b) overflow-text
c) overflow-marquee
d) none of the mentioned
View Answer
Answer: a
Explanation:
Syntax: overflow-style: auto | marquee-block
4. Which of the following property defines how content should behave when it exceeds the
width of its enclosing element?
a) overflow-y
b) overflow-x
c) overflow-z
d) overflow-width
View Answer
Answer: b
Explanation:
Syntax: overflow-x: auto | hidden
5. Which of the following property is used to give a 3-D sense of depth to an element?
a) animation
b) perspec
c) sense
d) perspective
View Answer
Answer: d
Explanation:
Syntax: perspective: none
6. Which of the following property is used to define whether an element should be resized
and, if so, upon what axis?
a) axis
b) resize
c) set-origin
d) set-axis
View Answer
Answer: b
Explanation:
Syntax: resize: both | horizontal | none
7. Which of the following property defines the alignment of Ruby text as defined by a <rt>
tag, in relation to base text defined by a <ruby> tag?
a) ruby-align
b) ruby-text
c) ruby
d) none of the mentioned
View Answer
Answer: a
Explanation:
Syntax: ruby-align: auto | center
8. Which of the following property sets the base color for a scroll bar, which will include the
scroll box, track, and scroll arrows?
a) scrollbar-base
b) scrollbar-base-color
c) scrollbar-background
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: scrollbar-base-color: color
9. Which of the following property defines a color for the face of a scroll bar, including arrow
regions and the scroll box?
a) scrollbar-face
b) scrollbar-face-color
c) scrollbar-face-background
d) scrollbar-background
View Answer
Answer: c
Explanation:
Syntax: scrollbar-face-color: color
10. Which of the following property defines a highlight color for a scroll bar and scroll
arrows?
a) scrollbar-color
b) scrollbar-highlight
c) scrollbar-highlight-color
d) scrollbar-highlight-background
View Answer
Answer: c
1. Which of the following property sets the size of the font?
a) font-size
b) font-variant
c) font-style
d) font-weight
View Answer
Answer: a
Explanation: Self-explainatory.
3. Which of the following font-weight property make the text lighter in relation to its parent?
a) unfocus
b) normal
c) lighter
d) normal
View Answer
Answer: c
Explanation: Self-explainatory.
advertisement
4. Which of the following property converts text to initial capitals, all uppercase, or all
lowercase?
a) text-transform
b) text
c) text-decoration
d) text-uppercase
View Answer
Answer: a
Explanation: Self-explainatory.
5. Which of the following font-variant property render text using the same letter case as in
the underlying code?
a) bold
b) small-caps
c) normal
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
6. Which of the following property sets the alignment of the last line of a text block?
a) overflow-wrap
b) text-align-last
c) text-transform
d) text-indent
View Answer
Answer: b
Explanation: Self-explainatory.
7. Which of the following property controls how spaces and word wrapping are handled?
a) spacing
b) text-space
c) white-space
d) word-spacing
View Answer
Answer: c
Explanation: Self-explainatory.
8. Which of the following property specifies what line decorations, if any, are added to the
text?
a) text-decoration-line
b) text-line-decoration
c) text-decoration-style
d) text-style-decoration
View Answer
Answer: a
Explanation: Self-explainatory.
10. Which of the following property allows long text, such as a URL, to be broken if it would
otherwise over?
a) text-transform
b) word-wrap
c) text-overflow
d) text-indent
View Answer
Answer: b
1. Which of the following is used to associate a font name to be used in a style sheet with
some downloadable font?
a) @font-face
b) @charset
c) @media
d) !important
View Answer
Answer: a
Explanation: None.
3. Which of the following font format is supported by all the latest browser?
a) EOT
b) WOFF2
c) SVG
d) WOFF
View Answer
Answer: d
Explanation: None.
advertisement
4. Which of the following media query describe output style portrait if height is greater than
or equal to width, landscape if the opposite?
a) grid
b) monochrome
c) resolution
d) orientation
View Answer
Answer: d
Explanation: None.
5. Which of the following media query describe the ratio of the width to the height of the
media?
a) ratio
b) aspect-ratio
c) deviceaspect-ratio
d) resolution
View Answer
Answer: b
Explanation: None.
6. Which of the following media query describe describes the height of the screen or full
height of the output page?
a) height
b) aspect-ratio
c) device-height
d) resolution
View Answer
Answer: c
Explanation: None.
9. Which of the following property sets a variation of the specified or default font family?
a) fonts
b) font-style
c) font-variant
d) font-weight
View Answer
Answer: c
Explanation: Syntax:
font-variant: normal | small-caps.
10. The @font-face rules assign different names to the regular and bold versions of the
font.State true or false.
a) True
b) False
View Answer
Answer: a
2. Which of the following display property value is described by treats the element as inline?
a) inline-block
b) list-item
c) block
d) inline
View Answer
Answer: d
Explanation: Self-explainatory.
3. Which of the following property defines the style for the bottom border of an element?
a) border-bottom-style
b) border-collapse
c) border-style-bottom
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
advertisement
4. Which of the following property defines the style for the left border of an element?
a) border-style
b) border-left-style
c) border-left-width
d) border-right
View Answer
Answer: b
Explanation: Self-explainatory.
5. Which of the following visibility property value is described by The element is not visible,
but the layout of surrounding elements is not affected?
a) visible
b) hidden
c) collapse
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
6. Which of the following display property value is described by used internally by browsers
to create list items. Of no practical value to web designers?
a) inline-block
b) list-item
c) group
d) none
View Answer
Answer: b
Explanation: Self-explainatory.
7. Which of the following property controls the horizontal overflow of a block or inline block?
a) overflow-x
b) overflow
c) overflow-y
d) overflow-k
View Answer
Answer: a
Explanation: Self-explainatory.
9. Which of the following property sets a consistent margin on all four sides of the affected
element?
a) boder
b) margin
c) padding
d) none fof the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
10. Which of the following box-sizing property value is described by width and height
include content, padding, and borders?
a) border-box
b) content-box
c) content-box
d) none fof the mentioned
View Answer
Answer: a
1. Which of the following property sets the background image to scroll or not to scroll with its
associated element’s content?
a) background-scroll
b) background-attach
c) background-attachment
d) background-allowance
View Answer
Answer: c
Explanation:
Syntax: background-attachment: scroll | fixed | inherit
advertisement
3. Which of the following property defines the color of an element’s right border?
a) border-right-colors
b) border-right-color
c) border-right
d) border-color
View Answer
Answer: b
Explanation:
Syntax: border-right-color: color | transparent
4. Which of the following property defines the space between cells in a table?
a) auto
b) border
c) spacing
d) border-spacing
View Answer
Answer: d
Explanation:
Syntax: border-spacing: non-negative length(s) | inherit
5. Which of the following property defines the visual style of up to four different sides of a
border?
a) border-color
b) border-img
c) border-visual
d) border-style
View Answer
Answer: b
Explanation:
Syntax: border-style: style
6. Which of the following property defines in a shorthand form the width, style, and color for
the top border of an element?
a) border-style
b) border-height
c) border-width
d) border-top
View Answer
Answer: d
Explanation:
Syntax: border-top: border-width border-style border-color;
7. Which of the following property sets the shadow for a box element?
a) shadow
b) set-shadow
c) canvas-shadow
d) box-shadow
View Answer
Answer: b
Explanation:
Syntax:box-shadow: none | inherit
9. Which of the following property defines a shadow color for the right and bottom edges of
a scroll bar?
a) scrollbar-darkshadow
b) scrollbar-shadow-color
c) scrollbar-darkshadow-color
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: scrollbar-darkshadow-color: color
10. Which of the following property defines a color for the right and bottom edges of a scroll
bar.
a) scrollbar-color
b) scrollbar-darkshadow-color
c) scrollbar-shadow
d) scrollbar-shadow-color
View Answer
Answer: d
advertisement
3. Which of the following property specifies whether the labels for an element’s list items are
positioned inside or outside the “box” defined by the listed item?
a) list-style
b) list-position
c) list-style-position
d) list-position-style
View Answer
Answer: c
Explanation:
Syntax: list-style-position: inside | outside | inherit
5. Which of the following property defines in a shorthand form the width, style, and color for
all four sides of an element’s border?
a) border
b) border-style
c) border-color
d) border-all
View Answer
Answer: a
Explanation:
Example: div {border: 2px double red;}
6. Which of the following property defines in a shorthand form the width, style, and color for
the left border of an element?
a) border
b) border-style
c) border-left
d) none of the mentioned
View Answer
Answer: b
Explanation:
Syntax: border-left: border-width border-style border-color;
8. Which of the following property influences the horizontal alignment of an element, making
it “float” toward the left or right margin of its containing element?
a) float
b) float-left
c) float-right
d) float-align
View Answer
Answer: d
Explanation:
Syntax: float: left | right | none | inherit;
9. Which of the following property sets the font face to be used for text?
a) font
b) font-text
c) font-family
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: font-family: font 1
10. Which of the following property sets the font size of text?
a) font
b) font-text
c) font-size
d) none of the mentioned
View Answer
Answer: c
1. Which of the following CSS Gradient Functions sets the direction and colors of a gradient
that fades from one color to the next in a straight line?
a) gradient()
b) line-gradient()
c) linear-gradient()
d) none of the mentioned
View Answer
Answer: d
Explanation: Self-explainatory.
2. Which of the following CSS Gradient Functions creates a circular or elliptical gradient,
and optionally sets its shape, size, and position?
a) radial-gradient()
b) circular-gradient()
c) elliptical-gradient()
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
3. Which of the following CSS Gradient Functions Creates a radial gradient that repeats
infinitely?
a) repeat-radial-gradient()
b) repeating-radial-gradient()
c) infinite-radial-gradient()
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
advertisement
6. Which of the following function creates a CSS gradient image that can be used anywhere
an image URL is required, including background-image, border-image, and list-style
properties?
a) canvas
b) gradient
c) animation
d) color
View Answer
Answer: b
Explanation: Self-explainatory.
7. Which of the following option best explain this code “background-image: repeating-radial-
gradient(circle at 50% 100%, #FFEB79, #D9CC3C 5%);”?
a) Creating Infinte circular Gradients
b) Creating Repeating Circular Gradients
c) Creating Repeating Radial Gradients
d) Creating Infinite Radial Gradients
View Answer
Answer: c
Explanation: Self-explainatory.
8. Which of the following option best explain this code “background-image: repeating-linear-
gradient(-45deg, #426A77, #FFF 6px);”?
a) Creating Straight Stripes
b) Creating Cubic Stripes
c) Creating Spiral Stripes
d) Creating Diagonal Stripes
View Answer
Answer: d
Explanation: Self-explainatory.
9. Which of the following option best explain this code “background-image: repeating-linear-
gradient(to right, #D9CC3C, #FFEB79 5%, #D9CC3C 10%);”?
a) Creating a Repeating Gradient
b) Creating a Mix Repeating Gradient
c) Creating a Shadow Repeating Gradient
d) Creating a Smooth Repeating Gradient
View Answer
Answer: d
1. Which of the following media feature describes the number of entries in the color lookup
table of the output device
a) color
b) color-index
c) color-value
d) color-@media
View Answer
Answer: b
Explanation: The ‘color-index’ media feature describes the number of entries in the color
lookup table of the output device. If the device does not use a color lookup table, the value
is zero
2. Which of the following Viewport Property sets the initial scaling factor?
a) scale
b) initial-scale
c) minimum-scale
d) user-scale
View Answer
Answer: b
Explanation: Self-explainatory.
3. Which of the following Viewport Property determines whether the display can be zoomed
in
and out?
a) scale
b) set-scale
c) adjust-scale
d) user-scalable
View Answer
Answer: d
Explanation: Self-explainatory.
advertisement
4. Which of the following @viewport Property sets the viewport height in the same way as
width?
a) height
b) width
c) viewpor-width
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
5. Which of the following @viewport Property locks the document in the specified
orientation, portrait or landscape?
a) orientation
b) resolution
c) landscape
d) portrait
View Answer
Answer: a
Explanation: Self-explainatory.
6. Which of the following Media Query describe the ratio of the device width to the device
height of the media?
a) device-aspect
b) device-aspect-ratio
c) device-aspect-query
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
7. Which of the following Media Query determines if output is grid, like a simple terminal or
phone, or bitmap, like a standard monitor or printer?
a) monochrome
b) grid
c) resolution
d) device-height
View Answer
Answer: b
Explanation: Self-explainatory.
8. Which of the following Media Query describes the scanning method of a TV?
a) orientation
b) scan
c) resolution
d) none of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
9. Which of the following Media Query determines if output is monochrome and how many
bits are used for gray display?
a) gray
b) chrome
c) monochrome
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
10. A media query consists of a media type and zero or more expressions that check for the
conditions of particular media features. State true or false.
a) True
b) False
View Answer
Answer: a
8. The __________ property specifies the type of positioning method used for an element.
a) align
b) float
c) position
d) padding
View Answer
Answer: c
Explanation: None.
a) Inline Styles
b) External Style Sheet
c) External Style Sheettyle Sheet
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
a) True
b) False
View Answer
Answer: a
This set of CSS Multiple Choice Questions & Answers focuses on “Using Advanced
Selectors”.
1. Which of the following selector selects all elements of E that have the attribute attr that
end with the given value?
a) E[attr^=value]
b) E[attr$=value]
c) E[attr*=value]
d) none of the mentioned
View Answer
Answer: b
Explanation:
Example: p[title$="!"] {color: red;}
advertisement
2. Which of the following selector selects the elements that are checked?
a) E ~ F
b) ::after
c) :checked
d) none of the mentioned
View Answer
Answer: c
Explanation:
Example: :checked {color: blue;}
3. Which of the following selector selects the elements that are the default among a set of
similar elements?
a) :default
b) :%
c) :disabled
d) none of the mentioned
View Answer
Answer: a
Explanation:
Example: :default {background-color: red;}
4. Which of the following selector selects an element that has no children?
a) :empty
b) :nochild
c) :inheritance
d) :no-child
View Answer
Answer: a
Explanation: None.
5. Which of the following selector selects the elements that are currently enabled?
a) :element
b) :empty
c) :enabled
d) none of the mentioned
View Answer
Answer: c
Explanation:
Example: input:enabled {background-color:white;}
6. Which of the following selector selects the element that is the first child of its parent that
is of its type?
a) :first-of-type
b) :last-child
c) ::first-line
d) ::first-letter
View Answer
Answer: a
Explanation:
Example: strong:first-of-type {font-size:bigger;}
7. Which of the following selector selects elements that do not match the selector s?
a) :!(s)
b) :nth-child(s)
c) :not(s)
d) none of the mentioned
View Answer
Answer: c
Explanation:
Example: *:not(h1) {color: black;}
8. Which of the following selector selects an element if it’s the only child of its parent?
a) :root
b) :nth-oftype(n)
c) :only-child
d) none of the mentioned
View Answer
Answer: c
Explanation:
Example: h1:only-child {color: blue;}
9. Which of the following selector selects the element that is the target of a referring URI?
a) :target
b) :selection
c) ::selection
d) :URI
View Answer
Answer: a
Explanation:
Example: :target{color:red;}
10. Which of the following selector applies styles to elements that are valid per HTML5
validations set either with the pattern or type
attributes?
a) :valid
b) :required
c) :optional
d) :invalid
View Answer
Answer: a
p {line-height: 150%;}
a) class Selectors
b) element Selectors
c) id Selectors
d) none of the mentioned
View Answer
Answer: b
Explanation: These selectors are called element selectors and are simply used
as follows:
element-name { /* properties */ }
5. A similar rule called the ____________ is specified using the plus sign (+) and is used to
select elements that would be siblings of each other.
a) class selectors
b) attribute selectors
c) adjacent-sibling selector
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
6. Which of the following selectors selects any tag with an id attribute set?
a) E#id
b) .class
c) #id
d) *
View Answer
Answer: c
Explanation: Example:#test {color: green;}
/* makes a tag with id=’test’ green */
7. Which of the following selectors selects direct descendents?
a) E > F
b) E F
c) E + F
d) E ~ F
View Answer
Answer: a
Explanation: Example:
body > p {background-color: yellow;}
/* makes all p tags that have the
body tag as their immediate parent
have the background color yellow */
8. Which of the following selectors selects siblings?
a) E.class
b) E ~ F
c) *
d) E, F, G
View Answer
Answer: b
Explanation: Example:
p ~ strong {font-style: italic;}
/* sets the font style to italic on
all strong tags that have a p tag
as a preceding sibling */
9. Which of the following selectors selects the specified elements of type E with a particular
class value?
a) E.class
b) E ~ F
c) *
d) E, F, G
View Answer
Answer: a
Explanation: Example:
h1.note {text-decoration: underline;}
/* underlines all h1 tags with
class='note' */
10. Which of the following selectors selects adjacent siblings?
a) E > F
b) E F
c) E + F
d) E ~ F
View Answer
Answer: c
1) count 1 if the declaration is from is a ‘style’ attribute rather than a rule with a selector, 0
otherwise (= a) (In HTML, values of an element’s “style” attribute are style sheet rules.
These rules have no selectors, so a=1, b=0, c=0, and d=0.)
2) count the number of ID attributes in the selector (= b)
3) count the number of other attributes and pseudo-classes in the selector (= c)
4) count the number of element names and pseudo-elements in the selector (= d)
h1.hidden {
display: none;
}
5. ____________ property sets the coordinates of the clipping shape that exposes or hides
the content of absolutely positioned elements
a) clammper
b) clip
c) clear
d) none of the mentioned
View Answer
Answer: b
Explanation:
clip: rect(coordinates) | auto | inherit
7. ____________ property defines whether table cell borders are connected or separate.
a) border-color
b) border
c) border-style
d) none of the mentioned
View Answer
Answer: d
Explanation: border-collapse roperty defines whether table cell borders are connected or
separate.
8. ________________ property sets the background image to scroll or not to scroll with its
associated element’s content
a) background
b) background-position
c) background-attachment
d) none of the mentioned
View Answer
Answer: c
Explanation: Example:
background-attachment: scroll | fixed | inherit
10. ______________ property defines whether table cell borders are connected or
separate.
a) pre
b) border-color
c) border-collapse
d) table
View Answer
Answer: c
1. Which of the following CSS property sets the opacity level for an element?
a) opacity
b) transparency
c) transparent
d) all of the mentioned
View Answer
Answer: a
Explanation: The opacity property defines the transparency-level, where 1 is opaque, 0.5 is
translucent, and 0 is completely transparent.
2. Which of the following property specifies the order of a flexible item relative to the rest of
the flexible items inside the same container?
a) sort
b) layout
c) order
d) asort
View Answer
Answer: c
Explanation: The CSS order property specifies the order used to lay out flex items in their
flex container. Elements are laid out in the ascending order of the order value.
4. Identify the CSS property that specifies the length of the space used for the tab
character.
a) size
b) tab-size
c) tab-space
d) all of the mentioned
View Answer
Answer: b
Explanation: The tab-size CSS property is used to customize the width of a tab.
6. Which of the following property allows long words to be able to be broken and wrap onto
the next line?
a) line-wrap
b) break-word
c) word-wrap
d) word-break
View Answer
Answer: c
Explanation: This property helps you break the words and wrap onto the next line to prevent
overflow of div.
7. Which of the following CSS property can be used to provide the flex-direction and flex-
wrap properties?
a) flex
b) flex-flow
c) flex-wrap
d) all of the mentioned
View Answer
Answer: b
Explanation: It is a shorthand for both flex-direction and flex-wrap.
8. Which of the following specifies how much the item will grow relative to the rest of the
flexible items inside the same container?
a) flex-scale
b) flex-size
c) flex-grow
d) flex-flow
View Answer
Answer: c
Explanation: Self-explainatory.
9. Which of the following property aligns the flexible container’s items when the items do not
use all available space on the main-axis?
a) wrap-content
b) fix-content
c) adjust-content
d) justify-content
View Answer
Answer: d
Explanation: The CSS justify-content property defines how the browser distributes space
between and around flex items along the main-axis of their container.
10. Choose the CSS property which specifies the placement of a table caption.
a) table-caption
b) cell-caption
c) caption-side
d) caption-adjust
View Answer
Answer: c
a) @important
b) !important!
c) !important
d) important!
View Answer
Answer: c
Explanation: If a particular rule should never be overridden by another rule, the !important
indication should be used. For a rule never to be ignored, insert the indication !important
just before the semicolon of the rule.
2. Which of the following option a rule consists of?
a) Tag
b) Selector
c) Declaration
d) Both Selector and Declaration
View Answer
Answer: d
Explanation: Self-explainatory.
advertisement
4. The ______________ is the link between the HTML document and the style. It specifies
what elements are affected by the declaration.
a) Tag
b) Selector
c) Declaration
d) Class
View Answer
Answer: b
Explanation: The selector is the link between the HTML document and the style. It specifies
what elements are affected by the declaration. The declaration is that part of the rule that
sets forth what the effect will be.
7. CSS3 ___________ let you display smooth transitions between two or more specified
colors
a) Float
b) Align
c) Gradients
d) Color
View Answer
Answer: b
Explanation: Earlier, you had to use images for these effects. However, by using CSS3
gradients you can reduce download time and bandwidth usage. In addition, elements with
gradients look better when zoomed, because the gradient is generated by the browser.
9. The __________ specifies style sheets for a source document according to the
conventions of the document language. For instance, in HTML, style sheets may be
included in the document or linked externally.
a) author
b) user
c) user-agent
d) none of the mentioned
View Answer
Answer: a
Explanation: Author. The author specifies style sheets for a source document according to
the conventions of the document language. For instance, in HTML, style sheets may be
included in the document or linked externally.
10.The __________ may be able to specify style information for a particular document. For
example, the user may specify a file that contains a style sheet or the user agent may
provide an interface that generates a user style sheet.
a) author
b) user
c) user-agent
d) none of the mentioned
View Answer
Answer: b
Explanation: User: The user may be able to specify style information for a particular
document. For example, the user may specify a file that contains a style sheet or the user
agent may provide an interface that generates a user style sheet (or behaves as if it did) .
11. Each property may also have a cascaded value of ___________ which means that, for
a given element, the property takes the same specified value as the property for the
element’s parent.
a) !important
b) delay
c) inherit
d) important
View Answer
Answer: c
2. A single _____________ rule can be used in an external sheet to define character set
encoding of the style rules and values.
a) @media
b) @charset
c) @font-face
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
3. An ___________ rule can be used to define style rules for multiple media types in a
single embedded style sheet
a) @media
b) @charset
c) @font-face
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
advertisement
5. Which of the following construct specifies that a style takes precedence over any
different, conflicting styles?
a) !important
b) <style>
c) #id
d) @media
View Answer
Answer: a
Explanation: None.
6. Which of the following property specifies the size of the mask?
a) box-sizing
b) box-shadow
c) box-reflect
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: -webkit-box-reflect: direction offset mask-box-image
7. Which of the following property is used to control column element breaks after an
associated element when flowing multicolumn text?
a) column-break
b) column-break-after
c) column-count
d) column-break-before
View Answer
Answer: b
Explanation:
Syntax: column-break-after: always | auto | avoid
8. Which of the following property defines the gap between columns in a multicolumn text
flow?
a) column-float
b) column-flow
c) column-gap
d) column-width
View Answer
Answer: c
Explanation:
Syntax: column-gap: length | normal
9. Which of the following property defines the style, width, and color of the rule divider
between
columns in a multicolumn text flow?
a) column
b) column-rule
c) column-change
d) column-check
View Answer
Answer: b
Explanation:
Syntax: column-rule: rule-width rule-style color
10. Which of the following property defines the width of a rule between columns in a
multicolumn text flow?
a) column-width
b) column-rule
c) column-float
d) column-rule-width
View Answer
Answer: d
1. Which of the following property sets in a shorthand form any or all background
properties?
a) font
b) background
c) background-color
d) background-position
View Answer
Answer: b
Explanation: Syntax:
background: background-color background-image background-repeat background-
attachment background- position;
2. Which of the following property defines whether table cell borders are connected or
separate?
a) border-style
b) border-collapse
c) border-color
d) border-bottom-width
View Answer
Answer: b
Explanation:
Syntax: border-collapse: collapse | separate | inherit
3. Which of the following property defines the style for the right border of an element?
a) border-left
b) border-right
c) border-right-style
d) border-style
View Answer
Answer: c
Explanation:
advertisement
4. Which of the following property defines the visual style of up to four different sides of a
border?
a) border-width
b) border-top
c) border
d) border-style
View Answer
Answer: d
Explanation:
Syntax: border-style: style [ style style style ]
5. Which of the following property sets the coordinates of the clipping shape that exposes or
hides the content of absolutely positioned elements?
a) clip
b) clamp
c) clip-wekit
d) clamp-webkit
View Answer
Answer: b
Explanation:
Syntax: clip: rect(coordinates) | auto | inherit
6. Which of the following property generates content in a document and is used with the
:before and :after pseudo-elements?
a) text
b) content
c) contents
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: content: normal | none | string
8. Which of the following property determines how the cursor displays when passed over
the affected element?
a) mouse
b) cursor
c) click
d) focus
View Answer
Answer: d
Explanation:
Syntax: cursor: url(address of cursor file)
9. Which of the following property is used to control the text direction, much like the dir
attribute for (X)HTML tags?
a) left
b) right
c) direction
d) direct
View Answer
Answer: c
Explanation:
Syntax: direction: ltr | rtl | inherit
10. Which of the following property specifies an element’s display type and can override an
element’s defined presentation?
a) content
b) display
c) visibility
d) none of the mentioned
View Answer
Answer: d
2. Which of the following property is used to define the animations that should be run?
a) animation-delay
b) animation-iteration-count
c) animation-duration
d) animation-name
View Answer
Answer: d
Explanation: None.
advertisement
3. Which of the following property is used to define the number of times an animation should
play?
a) animation-direction
b) animation-iteration-count
c) animation
d) animation-timing-function
View Answer
Answer: b
Explanation: None
4. Which of the following property is used to indicate whether the backside of an element is
visible if the element is rotated to display the back?
a) background-clip
b) backface-visibility
c) behavior
d) background-origin
View Answer
Answer: b
Explanation:
Syntax: backface-visibility: hidden | visible
5. Which of the following property defines a relationship between bound elements(s) and
some code or content?
a) behavior
b) anim
c) binding
d) none of the mentioned
View Answer
Answer: c
Explanation: None.
6. Which of the following property defines the width of each column in a multicolumn text
flow?
a) width
b) columns
c) filter
d) column-width
View Answer
Answer: d
Explanation: Implemented CSS3 and Browser-Specific Syntax: column-width: length | auto
7. Which of the following property is used to apply visual effects to associated elements?
a) filter
b) effect
c) adjust
d) none of the mentioned
View Answer
Answer: a
Explanation:
Syntax: filter: filtername(filtervalues) ... filtername(filtervalues)
8. Which of the following property defines the resampling method to use when stretching
images?
a) layout
b) ime-mode
c) image-rendering
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: image-rendering: auto | inherit | optimizeSpeed
9. Which of the following property specifies the direction in which a marquee should move?
a) marquee
b) marquee-play
c) marquee-direction
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: marquee-direction: forward | reverse
10. Which of the following property defines a mask to be used as a box’s overlay in order to
clip the box to a complex shape?
a) shadder
b) mask
c) mask-attachment
d) mask-image
View Answer
Answer: b
1. Which of the following element is used within the table element to define a caption?
a) <tablecaption>
b) <caption>
c) <table-cap>
d) <table-caption>
View Answer
Answer: b
Explanation: None.
2. Which of the following property is used to specify table borders in CSS?
a) table
b) border
c) table:border
d) none of the mentioned
View Answer
Answer: b
Explanation:
advertisement
3. Which of the following property sets whether the table borders are collapsed into a single
border or separated:?
a) border
b) border-collapse
c) collapse
d) table-border
View Answer
Answer: b
Explanation:
Example: table{ border-collapse: collapse;}
6. Which of the following property is used to control the space between the border and
content in a table?
a) border
b) margin
c) padding
d) resize
View Answer
Answer: c
Explanation:
Example: table{border: 4px solid black;}
1. Which of the following selector same as :after; changed under CSS3 to make pseudo-
elements obvious?
a) ::after
b) :after
c) #after
d) none of the mentioned
View Answer
Answer: a
Explanation:
Example: div::after {content: url(sectionend.gif);}
advertisement
4. Which of the following property is used in conjunction with the :before or :after pseudo-
elements?
a) text
b) generated-content
c) content
d) none of the mentioned
View Answer
Answer: c
Explanation:
Syntax: content: { { string | uri | counter}}
5. Which of the following property defines the text selection policy for various portions of a
document?
a) user-origin
b) user-select
c) user
d) all of the mentioned
View Answer
Answer: b
Explanation:
Syntax: user-select: all | none | text
6. Which of the following CSS3 property can be used to allow line breaks within words?
a) word-wrap
b) word-break
c) line-wrap
d) line-break
View Answer
Answer: b
Explanation:
Syntax: word-break: break-all | keep-all | normal
7. Which of the following property can be used to set text flow appropriate for European
alphabets or East Asian alphabets?
a) writing-mode
b) language-mode
c) text-mode
d) reading-mode
View Answer
Answer: a
Explanation:
Syntax: writing-mode: bt-lr | bt-rl
where the individual transition properties are defined in their own entries. Multiple
transitions can be listed separated by commas.
10. Which of the following property is used to define which properties a transition will be
applied to?
a) transition
b) transition-property
c) transition-wrap
d) transition-style
View Answer
Answer: b
2. Which of the following property is used to control the behavior of floating elements?
a) format
b) clean
c) clear
d) remove
View Answer
Answer: c
Explanation: Self-explainatory.
3. The default value for the float property is right.State true or false.
a) True
b) False
View Answer
Answer: b
Explanation: The default value for this property is none.
advertisement
img {
float: right;
}
a) left
b) top
c) bottom
d) right
View Answer
Answer: d
Explanation: Self-explainatory.
5. Which of the following property allows elements to be offset, rotated, scaled, and skewed
in a variety of different ways?
a) transform-style
b) transform
c) transition
d) transform-origin
View Answer
Answer: b
Explanation: None.
6. Which of the following property is used to define how nested items are rendered in a 3-D
space, the choice being either flattened or with their dimensions preserved?
a) transition-duration
b) transition-delay
c) transition
d) transform-style
View Answer
Answer: d
Explanation:
Syntax: transform-style: flat
7. Which of the following property is used to define the time it takes one iteration of an
animation to play?
a) transition-property
b) transition-timing
c) transition-duration
d) user-select
View Answer
Answer: c
Explanation:
Syntax transition-duration: time [,time]*
where time is a valid time value like 5s or 3500ms. The default value of time is 0, meaning
no animation plays.
8. Which of the following property sets the distance between an element’s right border and
the rightmost edge of its content?
a) auto
b) padding-left
c) padding-right
d) padding-top
View Answer
Answer: c
Explanation:
Syntax: padding-right: length | percentage | auto
9. Which of the following property is used to control page breaks when printing a document
after the bound element box ends?
a) page-inside
b) page-break-after
c) page-break-inside
d) page-break-before
View Answer
Answer: b
Explanation:
Syntax: page-break-after: always | auto
10.Which of the following property defines the style of quotation marks to be used with
embedded quotations?
a) article
b) para
c) quote
d) quotes
View Answer
Answer: d
1. Which of the following property defines the length of time that a transition takes?
a) transition
b) transition-duration
c) transform-duration
d) transition-property
View Answer
Answer: b
Explanation: None.
2. Which of the following property defines when the transition will start and it allows a
transition to begin execution some some period of time from when it is applied?
a) transform-delay
b) transition-delay
c) transform-duration
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
3. Which of the following transform property value defines a 2D translation?
advertisement
a) translate(x,y)
b) translate2d(x,y)
c) translate3d(x,y)
d) all of the mentioned
View Answer
Answer: a
Explanation: None.
4. Which of the following transform property value defines a translation, using only the value
for the X-axis?
a) translate(x)
b) translateZ(x)
c) translateY(x)
d) translateX(x)
View Answer
Answer: d
Explanation: None.
5. Which of the following transform property value defines a 3D scale transformation?
a) circle(x,y,z)
b) scale3d(x,y,z)
c) rotate3d(x,y,z,angle)
d) rotate(angle)
View Answer
Answer: b
Explanation: None.
6. Which of the following transform property value defines a perspective view for a 3D
transformed element?
a) perspective3d(n)
b) perspective(n,n,n)
c) perspective(n)
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
7. Which of the following transform property value defines a 2D skew transformation along
the X- and the Y-axis?
a) skewX(angle)
b) skewY(angle)
c) skew(x-angle,y-angle)
d) none of the mentioned
View Answer
Answer: c
Explanation: None.
8. Which of the following transform property value defines a 3D transformation, using a 4×4
matrix of 16 values?
a) matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)
b) matrix(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)
c) matrix2d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)
d) all of the mentioned
View Answer
Answer: a
Explanation: None.
9. Which of the following transform property value defines a 3D rotation along the Z-axis?
a) rotate-Z(angle)
b) rotate-Z-axis(angle)
c) rotateZ(angle)
d) all of the mentioned
View Answer
Answer: c
Explanation: None.
10. Which of the following transform property value defines a 3D rotation?
a) rotate3d(x,y,z,angle)
b) rotated(x,y,z,angle)
c) rotate-all(x,y,z,angle)
d) rotate(x,y,z,angle)
View Answer
Answer: a
1. Which of the following CSS Property selects an animation defined in an @keyframes rule
and applies it to the element?
a) animation
b) animation-name
c) animation-element
d) none of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
2. Which of the following CSS Property determines whether an animation should run in
reverse on some cycles?
a) animation
b) animation-run
c) animation-repeat
d) none of the mentioned
View Answer
Answer: d
Explanation: animation-direction : Determines whether an animation should run in reverse
on some cycles.
3. Which of the following CSS Property defines which property values to apply to the
element before the animation begins (if delayed) and after it ends?
a) animation-play
b) animation-delay
c) animation-fill-mode
d) animation-play-state
View Answer
Answer: c
Explanation: Self-explainatory.
advertisement
4. Which of the following CSS Property sets the pace of the transition to the next keyframe,
as described in the previous section?
a) animation-timing-function
b) animation-pace-function
c) animation-transition-function
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
5. Which of the following CSS property defines whether the animation is running or paused?
a) animation-pause-state
b) animation-state
c) animation-play-state
d) all of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
6. Which of the following property defines when the animation will start. It allows an
animation to begin execution some time after it is applied?
a) animation-stop
b) animation-delay
c) animation-start
d) animation-control
View Answer
Answer: b
Explanation: Self-explainatory.
7. Which of the following property specifies the number of times an animation should run?
a) animation-repeat
b) animation-count
c) animation-iteration-count
d) all of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
9. Which of the following property specifies the direction in which a marquee should move?
a) marquee
b) marquee-direction
c) marquee-time
d) none of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
10. @keyframes rule is used to define the properties that will control the audio/video
formats. State true or false.
a) True
b) False
View Answer
Answer: b
2. Which of the following CSS Property specifies the top offset of a positioned element?
a) top
b) up
c) reverse
d) fix
View Answer
Answer: a
Explanation: Self-explainatory.
3. Which of the following CSS Property Specifies the left offset of a positioned element?
a) right
b) left
c) bottom
d) up
View Answer
Answer: b
Explanation: Self-explainatory.
advertisement
4. Which of the following CSS Property sets the stacking order of positioned elements?
a) x-index
b) y-index
c) z-index
d) all of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
5. Which of the following CSS Property Defines the area of an absolutely positioned
element that remains visible?
a) clamp
b) clip
c) visibility
d) static
View Answer
Answer: b
Explanation: Self-explainatory.
6. Which of the following CSS Property specifies whether the labels for an element’s list
items are positioned inside or outside the “box” defined by the listed item?
a) list-style
b) list-position
c) list-style-position
d) all of the mentioned
View Answer
Answer: c
Explanation:
Syntax: list-style-position: inside | outside
7. Which of the following CSS Property defines the x-coordinate of the background-position
property?
a) background-position-x
b) background-position-y
c) background-x-axis
d) background-y-axis
View Answer
Answer: a
Explanation:
Syntax: background-position-x: length | percentage | left | center | right
8. Which of the following CSS Property specifies the position of the mask?
a) mask
b) mask-position
c) mask-origin
d) none of the mentioned
View Answer
Answer: b
Explanation: Syntax:
mask-position: xpos ypos.
9. Which of the following CSS Property specifies the x-coordinate in the position of the
mask?
a) mask-x
b) mask-x-origin
c) mask-position-x
d) mask-origin-x
View Answer
Answer: c
Explanation:
Syntax:
10. Which of the following Microsoft-introduced property defines the position of underlining
set by the text-decoration property?
a) text-underline
b) text-underline-origin
c) text-underline-position
d) none of the mentioned
View Answer
Answer: d
3. Which of the following property is used to define how nested items are rendered in a 3-D
space?
a) transform-style
b) transform
c) transform-origin
d) transform-3D
View Answer
Answer: a
Explanation: transform-style is used to define how nested items are rendered in a 3-D
space, the choice being either flattened or with their dimensions preserved. This property
affects the children of the element and not the element itself. Also, the property does not
cascade, so it is necessary to apply it at all levels.
advertisement
4. Which of the following rule allows users to import style rules from other style sheets?
a) @media
b) @important
c) @import
d) @style
View Answer
Answer: c
Explanation: The @import rule allows users to import style rules from other style sheets. If
an @import rule refers to a valid stylesheet, user agents must treat the contents of the
stylesheet as if they were written in place of the @import rule.
5. Which of the following property is a shorthand that resets all CSS properties?
a) reset
b) inital
c) all
d) delete
View Answer
Answer: c
Explanation: Self-explainatory.
6. Which of the following generate “virtual” rules representing their effects when running?
a) DOM’s
b) !important
c) CSS Animations
d) Inheritance
View Answer
Answer: c
Explanation: Self-explainatory.
7. The _______________ is the result of taking the computed value and completing any
remaining calculations to make it the absolute theoretical value used in the layout of the
document.
a) cascaded value
b) declared value
c) used value
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
8. The _________________ is the result of resolving the specified value.
a) cascaded value
b) computed value
c) specified value
d) declared value
View Answer
Answer: b
Explanation: Self-explainatory.
9. The ____________ represents the result of the cascade: it is the declared value that wins
the cascade.
a) specified Value
b) actual value
c) computed value
d) cascaded value
View Answer
Answer: d
Explanation: Self-explainatory.
10. The CSS cascade assigns a weight to each style rule. State true or false.
a) True
b) False
View Answer
Answer: a
1. Which of the following css property specifies an image to use as the background of an
element?
a) background
b) background-img
c) background-image
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
2. Which of the following css property specifies a delay for the transition effect?
a) transition-delay
b) transition-effect
c) transition
d) transition-duration
View Answer
Answer: a
Explanation: Self-explainatory.
3. Which of the following method rotates an element around its Y-axis at a given degree
using tranform 3D?
a) rotateY()
b) rotate-Y()
c) rotate-Yaxis()
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
advertisement
4. Which of the following property defines where a 3D element is based in the x- and the y-
axis?
a) transform-style
b) perspective(n)
c) perspective-origin
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
5. Which of the following css property repeats an image both horizontally and vertically?
a) background
b) background-image
c) background-repeat
d) background-position
View Answer
Answer: c
Explanation: Self-explainatory.
6. Which of the following CSS3 property specifies how nested elements are rendered in 3D
space?
a) transform
b) transform-style
c) transform-render
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
7. Which of the following CSS3 property specifies the intrinsic resolution of all raster images
used in/on the element?
a) image-orientation
b) image-rendering
c) image-resolution
d) all of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
8. Which of the following CSS3 property specifies how the contents of a replaced element
should be fitted to the box established by its used height and width?
a) object-fit
b) object-position
c) image-orientation
d) none of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
9. Which of the following CSS3 property specifies the alignment of the replaced element
inside its box?
a) object
b) object-allign
c) object-position
d) object-render
View Answer
Answer: c
Explanation: Self-explainatory.
10. Which of the following css property defines whether or not an element should be visible
when not facing the screen?
a) visibility
b) backface-control
c) backface-visibility
d) none of the mentioned
View Answer
Answer: c
1. Which of the following selector is used to select and style when you place mouse over it?
a) focus
b) hover
c) mouse
d) all of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
2. Which of the following method increases or decreases the size of an element using
tranform?
a) rotate()
b) scale()
c) translate()
d) matrix()
View Answer
Answer: b
Explanation: Self-explainatory.
3. Which of the following method moves an element from its current position using
tranform?
a) rotate()
b) scale()
c) translate()
d) matrix()
View Answer
Answer: c
Explanation: Self-explainatory.
advertisement
4. Which of the following property specifies the speed curve of the transition effect?
a) transition-delay
b) transition-duration
c) transition-timing-function
d) transition
View Answer
Answer: c
Explanation: Self-explainatory.
5. Which of the following method skews an element along the X-axis by the given angle
using tranform?
a) skewX()
b) skewy()
c) x-axis()
d) skew()
View Answer
Answer: a
Explanation: Self-explainatory.
6. Which of the following method skews an element along the X and Y-axis by the given
angles using tranform?
a) skewX()
b) skewy()
c) skew-X-Y()
d) skew()
View Answer
Answer: d
Explanation: Self-explainatory.
9. Which of the following transition-timing-function property lets you define your own values
in a cubic-bezier function
a) cubic(n,n,n,n)
b) matrix(n,n,n,n)
c) cubic-bezier(n,n,n,n)
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
10. Which of the following method combines all the 2D transform methods into one using
transform?
a) combine()
b) 2D-tranform()
c) matrix()
d) matrix-2D()
View Answer
Answer: c
a) <image>
b) <svg>
c) <img>
d) <graph>
View Answer
Answer: b
Explanation: Self-explainatory.
3. Which of the following element is used to create a SVG rectangle?
a) <rectangle>
b) <polygon>
c) <rect>
d) <square>
View Answer
Answer: c
Explanation: Self-explainatory.
4. Which of the following element is used to create a circle?
advertisement
a) <cir>
b) <round>
c) <circle>
d) <ellipse>
View Answer
Answer: c
Explanation: Self-explainatory.
5. Which of the following element is used to create an SVG ellipse?
a) <circle>
b) <ellipse>
c) <curve>
d) none of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
6. Which of the following is not an attribute used with SVG ellipse?
a) cx
b) cy
c) rr
d) ry
View Answer
Answer: c
Explanation: Self-explainatory.
a) <line>
b) <dot>
c) <ray>
d) <stick>
View Answer
Answer: a
Explanation: Self-explainatory.
8. Which of the following is attribute of SVG line?
a) x
b) y
c) x1
d) all of the mentioned
View Answer
Answer: d
Explanation: Self-explainatory.
9. Which of the following element is used to create any shape that consists of only straight
lines?
a) <polyogn>
b) <polyline>
c) <lines>
d) <multiline>
View Answer
Answer: b
Explanation: Self-explainatory.
10. Which of the following defines the color of a line, text or outline of an element?
a) text
b) stroke
c) line
d) all of the mentioned
View Answer
Answer: d
1. Which of the following css property should be used to make a responsive image?
a) float
b) max-width
c) margin-right
d) all of the mentioned
View Answer
Answer: d
Explanation: Self-explainatory.
2. What should be written in the blank of the code for resizing elements in Responsive Web
Design with Transitions
Code:
body { background-image: url(fog.jpg); background-size: cover;
background-repeat: no-repeat; color: #fff; font-family: Avenir, Arial, sans-
serif;
}
h1 { font-family: 'Calluna Sans', Arial, sans-serif; text-align: center;
font-size: 10rem; margin: 8rem auto;
}
h1 { font-family: 'Calluna Sans', Arial, sans-serif;
text-align: center; font-size: 10rem; margin: 8rem auto; transition: 1s font-
size linear;
}
______________ and (max-width: 1100px) {
h1 { font-size: 8rem; }
a) @media
b) @media screen
c) div
d) transform
View Answer
Answer: b
Explanation: None.
3. What should be written in the blank of the code for JQuery Code Used to Apply CSS3
Animations?
advertisement
Code:
_________ leftmove {
100% { transform: translateX(-70px); opacity: 1; }
}
_________ rightmove {
100% { transform: translateX(70px); opacity: 1; }
}
<script>
$(function() {
var footerBottom = $("#articlefooter").offset().top + $
("#articlefooter").height();
$(window).scroll(function() {
if ($(this).scrollTop() > (footerBottom - $(window).height())) {
131
$("#prevpage").css('animation', 'leftmove 1s 2s forwards');
$("#nextpage").css('animation', 'rightmove 1s 1s forwards');
});
});
</script>
a) @media
b) @keyframes
c) animation-name
d) !important
View Answer
Answer: b
Explanation: None.
5. Which of the following code set the webpage correctly displayed on a device?
View Answer
Answer: a
Explanation: Self-explainatory.
6. What does this code do?
Code:
@media only screen and (max-width: 500px) {
body {
background-color: lightblue;
}
}
a) If the browser window is smaller than 500px, the background color will change to
lightblue:
b) If the browser window is larger than 500px, the background color will change to lightblue:
c) The background color will change to lightblue
d) Nothing happens
View Answer
Answer: a
Explanation: Self-explainatory.
Code:
@media only screen and (orientation: landscape) {
body {
background-color: lightblue;
}
}
a) web page will have a lighblue background if the orientation is in landscape mode
b) web page will have a lighblue background if the orientation is not in landscape mode
c) web page will have a red background if the orientation is in landscape mode
d) None of the mentioned
View Answer
Answer: a
Explanation: Self-explainatory.
8. Which of the following css propery defines a relationship between bound elements(s) and
some code or content?
a) @import
b) @media
c) url-bind
d) binding
View Answer
Answer: d
Explanation:
Syntax: binding: none | url(bindingfile)
Code:
@media only screen and (max-width: 768px) {
class*="col-"] {
width: 100%;
}
}
a) When the screen gets larger than 768px, each column should have a width of 100%.
b) When the screen gets smaller than 768px, each column should have a width of 100%.
c) Error occured
d) None of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
10. Which of the following css propery define the properties that will be animated in an
animation rule?
a) @keyframes
b) animation-origin
c) transform
d) animation
View Answer
Answer: d
1. Which of the following css property allows elements to be offset, rotated, scaled, and
skewed in a variety of different ways?
a) transform-3D
b) transform-origin
c) transform
d) transition
View Answer
Answer: c
Explanation:
Syntax: transform: list of transform-functions | none
2. Which of the following css property is used to define a delay before an animation starts?
a) delay
b) transition-delay
c) transform-delay
d) none of the mentioned
View Answer
Answer: b
Explanation:
advertisement
3. Which of the following css property is used to define the time it takes one iteration of an
animation to play?
a) control
b) animation-duration
c) transition-duration
d) all of the mentioned
View Answer
Answer: c
Explanation:
4. Which of the following css property is used to define which properties a transition will be
applied to?
a) animation-property
b) transition-property
c) css3-property
d) none of the mentioned
View Answer
Answer: b
Explanation:
Syntax: transition-property: all | none | property-name-1
5. Which of the following css property is used to describe how the animation will play?
a) animation-timing-function
b) css3-timing-function
c) transform-timing-function
d) transition-timing-function
View Answer
Answer: d
Explanation:
Syntax:transition-timing-function transition-timing-function:
timingfunction,timingfunction2,...timingfunctionN]
6. Which of the following css property is used to define a delay before an animation starts?
a) transform-delay
b) delay-function
c) delay-animation
d) animation-delay
View Answer
Answer: d
Explanation: None.
Syntax: animation-delay: time1 [,..timeN]
7. Which of the following css property is used to indicate if an animation plays in reverse or
repeats itself every other iteration?
a) animation-iteration
b) animation-check
c) animation-direction
d) animation-state
View Answer
Answer: c
Explanation:
Syntax: animation-direction: normal | alternate [,normal | alternate
8. Which of the following css property is used to define the time it takes one iteration of an
animation to play?
a) animation-duration
b) animation-time
c) animation-value
d) none of the mentioned
View Answer
Answer: a
Explanation:
Syntax: animation-duration: time
9. Which of the following css property is used to define the number of times an animation
should play?
a) scale-iteration-count
b) transtion-iteration-count
c) animation-iteration-count
d) all of the mentioned
View Answer
Answer: c
Explanation:
Syntax: animation-iteration-count: number | infinite
10. Which of the following css property is used to define the animations that should be run?
a) animation-run
b) animation-name
c) transtion-name
d) none of the mentioned
View Answer
Answer: d
1. Which of the following CSS3 property is used to tell the browser what the sizing
properties should be include?
a) box-sizing
b) box-model
c) box-design
d) box-redesign
View Answer
Answer: a
Explanation: Self-explainatory.
2. Which of the following CSS3 property specifies where to navigate when using the arrow-
down navigation key?
a) down
b) nav-down
c) arrow-down
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
3. Which of the following CSS3 property specifies the sequential navigation order for an
element?
a) nav
b) class
c) nav-index
d) class-index
View Answer
Answer: c
Explanation: Self-explainatory.
advertisement
4. Which of the following nav-left value sets it’s value to default value?
a) target-name
b) id
c) inital
d) inherit
View Answer
Answer: c
Explanation: Self-explainatory.
5. Which of the following CSS3 property adds space between an outline and the edge or
border of an element?
a) offset
b) outline
c) outline-offset
d) none of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
6. Which of the following outline-offset value sets the distance the outline is outset from the
border edge?
a) distance
b) length
c) initial
d) all
View Answer
Answer: b
Explanation: Self-explainatory.
7. Which of the following CSS3 property specifies whether or not an element is resizable by
the user?
a) resize
b) length
c) inherit
d) none of the mentioned
View Answer
Answer: b
Explanation: Self-explainatory.
8. Which of the following CSS3 property specifies where to navigate when using the arrow-
up navigation key?
a) nav-upper
b) nav-top
c) nav-up
d) all of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
9. Which of the following CSS3 property specifies where to navigate when using the arrow-
right navigation key?
a) right
b) nav-right
c) nav-side
d) none of the mentioned
View Answer
Answer: c
Explanation: Self-explainatory.
10. Which of the following nav-right value is used to the inherits this property from its parent
element?
a) auto
b) id
c) target-name
d) inherit
View Answer
Answer: d
1. Which of the following Module is not available in CSS3.
a) DOMs
b) Fonts
c) Backgrounds and Borders
d) Color
View Answer
Answer: a
Explanation: The Document Object Model (DOM) is a programming API for HTML and XML
documents. It defines the logical structure of documents and the way a document is
accessed and manipulated.
2. What module introduces the ability to modify CSS property values over time, such as
position or color, to create animated layouts?
a) 3D Transforms
b) Animations
c) 2D Transforms
d) Box Model
View Answer
Answer: b
Explanation: Visit www.w3.org/TR/css3-animations to know more about it.
3. What module defines the management of generated content for print output, including
crop mark indication, header/footer handling, and much more?
a) Behavioral Extensions
b) Generated and Replaced Content
c) Generated Content for Paged Media
d) Grid Positioning
View Answer
Answer: c
Explanation: Visit www.w3.org/TR/css3-gcpm to know more about it.
advertisement
4. What module defines the handling of lists, including marker styles and some aspects of
counters?
a) Line Layout
b) Lists
c) Media Queries
d) Namespaces
View Answer
Answer: b
Explanation: Visit www.w3.org/TR/css3-lists to know more about it.
5. What module expands the absolute and relative units of measure, including significant
changes to support animation and aural changes with time (s and ms) and angle (deg and
rad) values?
a) Transitions
b) Template Layout
c) Web Fonts
d) Values and Units
View Answer
Answer: d
Explanation: Visit www.w3.org/TR/css3-values to know more about it.
/* sets the font style to italic on all strong tags that have a p tag as a preceding sibling */
7. Which of the following selector is used to selects the elements that are the default among
a set of similar elements?
a) ::after
b) :disabled
c) :default
d) :checked
View Answer
Answer: c
Explanation:
:default {background-color: red;}
8. Which of the following selector is used to selects the element that is the first child of its
parent that is of its type?
a) :nth-child(n)
b) ::first-line
c) :last-of-type
d) :first-of-type
View Answer
Answer: d
Explanation:
strong:first-of-type {font-size: bigger;}
/* sets the font size bigger on the first strong tag of its parent */
9. Which of the following selector is used to selects the element that is the nth child of its
parent?
a) :nth-child(n)
b) ::first-line
c) :last-of-type
d) :first-of-type
View Answer
Answer: a
Explanation:
div:nth-child(2) {background-color: red;}
/* sets the background color to red if the div is its parent’s second child */
10. Which of the following selector is used to selects the element that is the root of the
document?
a) :only-of-type
b) :target
c) :root
d) ::selection
View Answer
Answer: d
Explanation:
:root {background-color: blue;}
11. Which of the following selector is used to select elements that are read-only. When
applied to form elements, this would select fields with the readonly attribute set?
a) :valid
b) :target
c) :read-only
d) :required
View Answer
Answer: c
Explanation: input:read-only {color: gray;}
/* put all read only fields in gray */
12. Which of the following measurement represent seconds?
a) s
b) se
c) sec
d) second
View Answer
Answer: a
1. Which of the following property is used to control column element breaks after an
associated element when flowing multicolumn text?
a) column-break
b) column-break-after
c) column-break-before
d) multicolumn-break-after
View Answer
Answer: b
Explanation:
Syntax: column-break-after: always | auto | avoid
2. Which of the following property is used to control column element breaks before the
associated element when flowing multicolumn text?
a) multicolumn
b) column-break-before
c) column-break
d) multicolumn-break-before
View Answer
Answer: b
Explanation:
advertisement
3. Which of the following property defines the number of columns in a multicolumn text
flow?
a) columns
b) column-flow
c) column-number
d) column-count
View Answer
Answer: d
Explanation:
Syntax: column-count: integer | auto
4. Which of the following property defines the gap between columns in a multicolumn text
flow?
a) column-rule-flow
b) column-gap
c) column-rule
d) none of the mentioned
View Answer
Answer: b
Explanation:
Syntax: column-gap: length | normal
5. Which of the following property defines the style of the divider rule between columns in a
multicolumn text flow?
a) columns
b) column-flow
c) column-style
d) none of the mentioned
View Answer
Answer: d
Explanation:
Syntax: column-rule-style: dashed | dotted
6. Which of the following property defines the width of a rule between columns in a
multicolumn text flow?
a) column-rule-style
b) column-width
c) column-rule-width
d) columns
View Answer
Answer: c
Explanation:
Syntax: column-rule-width: non-negative length
7. Which of the following property is a shorthand definition of the number of columns and
their widths in a multicolumn text flow?
a) column-width
b) column-style
c) columns
d) filter
View Answer
Answer: c
Explanation:
Syntax: columns: column-count width
8. Which of the following property defines the color of any rules between columns in a
multicolumn text flow?
a) column-color
b) column-rule-color
c) column-rule-style
d) column-rule-decoration
View Answer
Answer: b
Explanation:
Syntax: column-rule-color: color
9. Which of the following property is used to apply visual effects to associated elements.
a) Alpha
b) BasicImage
c) Filter
d) Blur
View Answer
Answer: c
Explanation:
Syntax:
filter: filtername(filtervalues) ... filtername(filtervalues)
10. Which of the following property defines the resampling method to use when stretching
images?
a) interpolation-mode
b) image-rendering
c) ime-mode
d) layout-grid
View Answer
Answer: b
advertisement
2. Which one can animate the width of search input when get focus?
a) focus
b) transition
c) outline
d) color
View Answer
Answer: b
Explanation: For animating the width of search input when it gets focus we used CSS
transition property,
input[type=text] {-webkit-transition: width 09s ease-in-out; transition:
width 0.9s ease-in-out; } input[type=text]:focus {width:100%;}
4. Which of the following is not the pseudo class for CSS Basic UI Level3?
a) :optional
b) :read-only
c) :valid
d) :checked
View Answer
Answer: d
Explanation: CSS Basic UI Level 3 has many pseudo-classes like :widget, :invalid, :valid,
:in-range, :required, :read-write, :read-only, :optional, :out-of-range. CSS Selector Level 3
has the classes :disabled, :enabled, :indeterminate, :checked.
2. Which of the following value sits to the left of the block of text?
a) outside
b) left
c) inside
d) right
View Answer
Answer: a
Explanation: List are indented into the page by default and list-style-position property
indicates whether the marker should appear on inside or outside box containing main
points. This property can take two values outside and inside. The marker sits to the left of
the block of text, this is the default behavior if this property is not used.
advertisement
5. Which of the following will take the element out of normal flow?
a) fixed positioning
b) floating elements
c) relative positioning
d) absolute positioning
View Answer
Answer: b
Explanation: Floating an element allows us to take that element out of normal flow and
position it too far left or right of a containing box. The floated element becomes block-level
element around which other content can flow.
7. Which of the property is not used for positioning columns next to each other?
a) float
b) width
c) margin
d) border
View Answer
Answer: d
Explanation: Many web pages used multiple columns in their design. The three CSS
properties are used to position columns next to each other. Width, margin, and float. Width
sets the width of the column, float positions columns next to each other, margin creates a
gap between columns.
10. Which should be used to overlay text on image with high contrast?
a) screen
b) high contrast
c) low contrast
d) opaque
View Answer
Answer: a
Explanation: To overlay text on an image with high contrast, we can place a semi-
transparent background color or “screen” behind the text to improve legibility. The majority
of photographs have quite high contrast, that means they are not ideal for use as
background image.
11. Using actual image with inline image method is also known as __________
a) The Langridge method
b) Radu Darvas Shim
c) The Levin Technique
d) Phark method
View Answer
Answer: d
Explanation: In this method, we use the actual image for image replacement. The image
has alt text that will be shown when images are turned off. This technique does not seem to
be good for SEO. Images will still be visible with CSS turned off and images kept on.
The pseudo element pushes text aside. The text then overflows and is hidden by using
overflow: hidden property.
2. Which of the following does not break long URLs into a shorter one?
a) Internet Explorer
b) Chrome
c) Firefox
d) Opera
View Answer
Answer: a
Explanation: word-wrap breaks long URLs when they reach a certain limit. This property is
basically supported in a wide range of browsers even in IE 6, it works in chrome when
printing. Firefox automatically breaks long URLs, Internet Explorer has no capability for
breaking long URLs into the shorter one.
7. Which value specifies the number of colors the device can display?
a) color-index
b) color-gamut
c) color
d) max-color
View Answer
Answer: a
Explanation: The number of colors the device can display is specified by color-index, color-
gamut specifies the approximate range of colors that are supported by a user agent and
output device. The number of bits per color component for the output device is specified by
color value.
8. Which value will define the viewport width?
a) width
b) resolution
c) pointer
d) update
View Answer
Answer: a
Explanation: Width specifies the width of the viewport, update specify how quickly can
output device modify the appearance of the content, the scan is set for scanning process of
the output device, the resolution of output device using dpi or dpcm is by resolution.
1. Which of the following will select all elements within the class?
a) .class
b) #id
c) element
d) element>element
View Answer
Answer: a
Explanation: .class selects all elements within the given class, #id selects the element within
the given id, element>element selects all <p> elements where parent is <div> element,
element selects all <p> elements.
2. Which of the following selects all <div> elements and all <p> elements?
a) element,element
b) element+element
c) element,element
d) element element
View Answer
Answer: c
Explanation: element,element selects all <div> elements and all <p> elements, element
element selects all <p> elements inside <div> elements, element>element selects all <p>
elements where parent is a <div> element, element+element selects all <p> elements that
are placed immediately after <div> element.
4. Which of the following selects every <a> element whose href attribute value contains the
given substring?
a) attribute$=value
b) attribute*=value
c) attribute^=value
d) attribute|=value
View Answer
Answer: b
Explanation: attribute*=value selects every <a> element whose href attribute value contains
the given substring, attribute$=value selects every <a> element whose href attribute value
ends with the given href, attribute^=value selects every <a> element element whose href
attribute value begins with “https”.
5. Which of the following selects every <p> element that has no children?
a) :empty
b) :enabled
c) :checked
d) :disabled
View Answer
Answer: a
Explanation: :empty selects every <p> element that has no children including text nodes,
:checked selects every checked <input> element, :disabled selects every disabled <input>
element, :enabled selects every enabled <input> element.
8. Which of the following will select every <p> element that is the only child of its parent?
a) :only-child
b) :only-of-type
c) :optional
d) :out-of-range
View Answer
Answer: a
Explanation: :only-child selects every <p> element that is the only child of its parent, :only-
of-type selects every <p> element that is the only child of its parent, :optional selects input
elements with no “required” attribute.
2. Which class is used for setting perspective and scroll properties for the page?
a) .wrapper
b) .section
c) .static
d) .parallax
View Answer
Answer: a
Explanation: .wrapper sets the perspective and scroll properties for the whole page, .section
is for size, display and text properties, mostly not relevant to parallax effect, .static add a
background to a section, just for demonstration.
3. Which of the following is used for adding perspective background images for each
section?
a) .bg1
b) .parallax
c) .static
d) .section
View Answer
Answer: a
Explanation: .bg1, .bg2 adds the respective background images for each section, we can
use img tag also, .parallax adds an ::after pseudo-element with the background image and
transforms needed for the parallax effect.
advertisement
9. Which of the following position element is not affected by the top, bottom, left etc.
property?
a) static
b) clip
c) relative
d) absolute
View Answer
Answer: a
1. What is the default value of object-fit?
a) fill
b) contain
c) none
d) cover
View Answer
Answer: a
Explanation: Object-fit has can be set with five values. When set to the value fill, it is the
default value which stretches the image to fit the content box, regardless of its aspect-ratio,
contain increases or decreases the size of the image to fill the box whilst preserving its
aspect-ratio.
2. Which value will compare the difference between none and contain?
a) contain
b) scale-down
c) none
d) cover
View Answer
Answer: b
Explanation: When setting the value to scale-down the image will compare the difference
between none and contain in order to find the smallest concrete object size when set to
cover the image will fill the height and width of its box.
i) Notepad
ii) Notepad++
iv) PDT
a) Only iv)
b) i), ii), iii) and iv)
c) i), ii) and iii)
d) Only iii)
View Answer
Answer: b
Explanation: Any of the above editors can be used to type php code and run it.
5. Which of the following must be installed on your computer so as to run PHP script?
i) Adobe Dreamweaver
ii) XAMPP
iv) IIS
i) /?
ii) //
iii) #
iv) /* */
a) Only ii)
b) i), iii) and iv)
c) ii), iii) and iv)
d) Both ii) and iv)
View Answer
Answer: c
Explanation: /* */ can also be use to comment just a single line although it is used for
paragraphs. // and # are used only for single line comment.
8. Which of the following PHP statement/statements will store 111 in variable num?
1. <?php
2. $num = 1;
3. $num1 = 2;
4. print $num . "+". $num1;
5. ?>
a) 3
b) 1+2
c) 1.+.2
d) Error
View Answer
Answer: b
Explanation: .(dot) is used to combine two parts of the statement. Example ($num . “Hello
World”) will output 1Hello World.
1. <?php
2. $num = "1";
3. $num1 = "2";
4. print $num+$num1;
5. ?>
a) 3
b) 1+2
c) Error
d) 12
View Answer
Answer: a
a) 5 === 5
b) Error
c) 1
d) False
View Answer
Answer: c
Explanation: === operator returns 1 if $a and $b are equivalent and $a and $b have the
same type.
advertisement
1. <?php
2. $num = 10;
3. echo 'What is her age? \n She is $num years old';
4. ?>
View Answer
Answer: a
Explanation: When a string is enclosed within single quotes both variables and escape
sequences will not be interpreted when the string is parsed.
4. Which of the conditional statements is/are supported by PHP?
i) if statements
a) Only i)
b) i), ii) and iv)
c) ii), iii) and iv)
d) i), ii), iii) and iv)
View Answer
Answer: d
Explanation: All are conditional statements supported by PHP as all are used to evaluate
different conditions during a program and take decisions based on whether these conditions
evaluate to true of false.
1. <?php
2. $team = "arsenal";
3. switch ($team) {
4. case "manu":
5. echo "I love man u";
6. case "arsenal":
7. echo "I love arsenal";
8. case "manc":
9. echo "I love manc"; }
10. ?>
a) I love arsenal
b) Error
c) I love arsenalI love manc
d) I love arsenalI love mancI love manu
View Answer
Answer: c
Explanation: If a break statement isn’t present, all subsequent case blocks will execute until
a break statement is located.
a) i) and ii)
b) i), ii) and iii)
c) i), ii), iii) and iv)
d) Only iv)
View Answer
Answer: c
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.
1. <?php
2. $user = array("Ashley", "Bale", "Shrek", "Blank");
3. for ($x=0; $x < count($user); $x++) {
4. if ($user[$x] == "Shrek") continue;
5. printf ($user[$x]);
6. }
7. ?>
a) AshleyBale
b) AshleyBaleBlank
c) ShrekBlank
d) Shrek
View Answer
Answer: b
Explanation: The continue statement causes execution of the current loop iteration to end
and commence at the beginning of the next iteration.
9. What will be the value of $a and $b after the function call in the following PHP code?
1. <?php
2. function doSomething( &$arg ) {
3. $return = $arg;
4. $arg += 1;
5. return $return;
6. }
7. $a = 3;
8. $b = doSomething( $a );
9. ?>
a) a is 3 and b is 4
b) a is 4 and b is 3
c) Both are 3
d) Both are 4
View Answer
Answer: b
Explanation: $a is 4 and $b is 3. The former because $arg is passed by reference, the latter
because the return value of the function is a copy of the initial value of the argument.
i) $3hello
ii) $_hello
iii) $this
iv) $This
a) Only ii)
b) Only iii)
c) ii), iii) and iv)
d) ii) and iv)
View Answer
Answer: d
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 define variable name.
advertisement
1. <?php
2. $foo = 'Bob';
3. $bar = &$foo;
4. $bar = "My name is $bar";
5. echo $bar;
6. echo $foo;
7. ?>
a) Error
b) My name is BobBob
c) My name is BobMy name is Bob
d) My name is Bob Bob
View Answer
Answer: c
Explanation: Firstly, the line $bar = &$foo; will reference $foo via $bar. So $bar is assigned
value Bob. Therefore $bar = “My name is $bar”; will print My name is Bob($bar=Bob as said
before).
3. Which of the following PHP statements will output Hello World on the screen?
a) i) and ii)
b) i), ii) and iii)
c) i), ii), iii) and iv)
d) i), ii) and iv)
View Answer
Answer: b
Explanation: echo(), print() and printf() all three can be used to output a statement onto the
screen. The sprintf() statement is functionally identical to printf() except that the output is
assigned to a string rather than rendered to the browser.
1. <?php
2. $color = "maroon";
3. $var = $color[2];
4. echo "$var";
5. ?>
a) a
b) Error
c) $var
d) r
View Answer
Answer: d
Explanation: PHP treats strings in the same fashion as arrays, allowing for specific
characters to be accessed via array offset notation. In an array, index always starts from 0.
So in the line $var = $color[2]; if we count from start ‘r’ comes at index 2. So the output will
be r.
1. <?php
2. $score = 1234;
3. $scoreboard = (array) $score;
4. echo $scoreboard[0];
5. ?>
a) 1
b) Error
c) 1234
d) 2
View Answer
Answer: c
Explanation: The (array) is a cast operator which is used for converting values from other
data types to array.
1. <?php
2. $total = "25 students";
3. $more = 10;
4. $total = $total + $more;
5. echo "$total";
6. ?>
a) Error
b) 35 students
c) 35
d) 25 students
View Answer
Answer: c
Explanation: The integer value at the beginning of the original $total string is used in the
calculation. However if it begins with anything but a numerical value, the value will be 0.
1. <?php
2. function track() {
3. static $count = 0;
4. $count++;
5. echo $count;
6. }
7. track();
8. track();
9. track();
10. ?>
a) 123
b) 111
c) 000
d) 011
View Answer
Answer: a
Explanation: Because $count is static, it retains its previous value each time the function is
executed.
1. <?php
2. $a = "clue";
3. $a .= "get";
4. echo "$a";
5. ?>
a) get
b) true
c) false
d) clueget
View Answer
Answer: d
3. Which type of function call is used in line 8 in the following PHP code?
advertisement
1. <?php
2. function calc($price, $tax)
3. {
4. $total = $price + $tax;
5. }
6. $pricetag = 15;
7. $taxtag = 3;
8. calc($pricetag, $taxtag);
9. ?>
a) Call By Value
b) Call By Reference
c) Default Argument Value
d) Type Hinting
View Answer
Answer: a
Explanation: If we call a function by value, we actually pass the values of the arguments
which are stored or copied into the formal parameters of the function. Hence, the original
values are unchanged only the parameters inside the function changes.
1. <?php
2. function calc($price, $tax="")
3. {
4. $total = $price + ($price * $tax);
5. echo "$total";
6. }
7. calc(42);
8. ?>
a) Error
b) 0
c) 42
d) 84
View Answer
Answer: c
Explanation: You can designate certain arguments as optional by placing them at the end of
the list and assigning them a default value of nothing.
i) function()
ii) €()
iii) .function()
iv) $function()
a) Only i)
b) Only ii)
c) i) and ii)
d) iii) and iv)
View Answer
Answer: b
Explanation: A valid function name can start with a letter or underscore, followed by any
number of letters, numbers, or underscores. According to the specified regular expression
([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*), a function name like this one is valid.
1. <?php
2. function a()
3. {
4. function b()
5. {
6. echo 'I am b';
7. }
8. echo 'I am a';
9. }
10. a();
11. a();
12. ?>
a) I am a
b) I am bI am a
c) Error
d) I am a Error
View Answer
Answer: a
Explanation: The output will be “I am a” as we are calling a(); so the statement outside the
block of function b() will be called.
1. <?php
2. function a()
3. {
4. function b()
5. {
6. echo 'I am b';
7. }
8. echo 'I am a';
9. }
10. b();
11. a();
12. ?>
a) I am b
b) I am bI am a
c) Error
d) I am a Error
View Answer
Answer: c
Explanation: The output will be Fatal error: Call to undefined function b(). You cannot call a
function which is inside a function without calling the outside function first. It should be a();
then b();
1. <?php
2. $op2 = "blabla";
3. function foo($op1)
4. {
5. echo $op1;
6. echo $op2;
7. }
8. foo("hello");
9. ?>
a) helloblabla
b) Error
c) hello
d) helloblablablabla
View Answer
Answer: c
Explanation: If u want to put some variables in function that was not passed by it, you must
use “global”. Inside the function type global $op2.
a) Error
b) $msg
c) 0
d) Will this work
View Answer
Answer: d
2. Which one of the following PHP functions can be used to find files?
a) glob()
b) file()
c) fold()
d) get_file()
View Answer
Answer: a
Explanation: The function glob() returns an array of filenames or directories which matches
a specified pattern. The function returns an array of files/directories, or it will return FALSE
on failure. Here is an example-
advertisement
3. Which of the following PHP functions can be used to get the current memory usage?
a) get_usage()
b) get_peak_usage()
c) memory_get_usage()
d) memory_get_peak_usage()
View Answer
Answer: c
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.
4. Which of the following PHP functions can be used for generating unique ids?
a) uniqueid()
b) id()
c) md5()
d) mdid()
View Answer
Answer: a
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.
1. <?php
2. echo chr(52);
3. ?>
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: d
Explanation: The chr() function returns a character from the specified ASCII value. We can
specify ASCII value in decimal, octal, or hex values. The Octal values are defined as a
leading 0, while hex values are defined as a leading 0x. Since the ASCII value of 4 is 52,
thus 4 was displayed.
1. <?php
2. echo ord ("hi");
3. ?>
a) 106
b) 103
c) 104
d) 209
View Answer
Answer: c
Explanation: The ord() function returns the ASCII value of the first character of a string. The
ASCII value of h is 104, thus 104 was displayed.
1. <?php
2. $str = "Hello World";
3. echo wordwrap($str,5,"<br>\n");
4. ?>
a) Hello World
b)
Hello
World
c)
Hell
o wo
rld
d) World
View Answer
Answer: b
Explanation: The wordwrap() function wraps a string into new lines when it reaches a
specific length.
1. <?php
2. echo ucwords("i love my country");
3. ?>
a) I love my country
b) i love my Country
c) I love my Country
d) I Love My Country
View Answer
Answer: d
Explanation: The ucwords() function converts the first character of each word in a string to
uppercase.
1. <?php
2. echo lcfirst("welcome to India");
3. ?>
a) welcome to India
b) welcome to india
c) Welcome to India
d) Welcome to india
View Answer
Answer: a
1. <?php
2. $states = array("Karnataka" => array
3. ("population" => "11,35,000", "capital" => "Bangalore"),
4. "Tamil Nadu" => array( "population" => "17,90,000",
5. "capital" => "Chennai") );
6. echo $states["Karnataka"]["population"];
7. ?>
a) Karnataka 11,35,000
b) 11,35,000
c) population 11,35,000
d) Karnataka population
View Answer
Answer: b
Explanation: In the following PHP code, the variable states are treated as a
multidimensional array and accordingly traverse it to get the value of ‘Karnataka’s
population’.
4. Which of the following PHP function will return true if a variable is an array or false if it is
not an array?
a) this_array()
b) is_array()
c) do_array()
d) in_array()
View Answer
Answer: b
Explanation: The function is_array() is an inbuilt function in PHP which is used to check
whether a variable is an array or not. Its prototype follows: boolean is_array(mixed variable).
1. <?php
2. $state = array ("Karnataka", "Goa", "Tamil Nadu",
3. "Andhra Pradesh");
4. echo (array_search ("Tamil Nadu", $state) );
5. ?>
a) True
b) 1
c) False
d) 2
View Answer
Answer: d
Explanation: The array_search() function searches an array for a specified value, returning
its key if located and FALSE otherwise.
1. <?php
2. $fruits = array ("apple", "orange", "banana");
3. echo (next($fruits));
4. echo (next($fruits));
5. ?>
a) orangebanana
b) appleorange
c) orangeorange
d) appleapple
View Answer
Answer: a
Explanation: The next() function returns the value of the next element in the array. In the
first ‘next($fruits)’ call, it will print orange which is next to apple and so on.
8. Which of the following function is used to get the value of the previous element in an
array?
a) last()
b) before()
c) prev()
d) previous()
View Answer
Answer: c
Explanation: The prev() function returns the previous element in the array.
a) 3
b) 4
c) 5
d) 6
View Answer
Answer: d
Explanation: The 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.
1.<?php
2.$cars = array("Volvo", "BMW", "Toyota");
3.echo "I like " . $cars[2] . ", " . $cars[1] . " and " . $cars[0] .
".";
4.?>
1.<?php
2.$fname = array("Peter", "Ben", "Joe");
3.$age = array("35", "37", "43");
4.$c = array_combine($age, $fname);
5.print_r($c);
6.?>
a) Array (Peter Ben Joe)
b) Array ([Peter] => 35 [Ben] => 37 [Joe] => 43)
c) Array (35 37 43)
d) Array ([35] => Peter [37] => Ben [43] => Joe)
View Answer
Answer: d
Explanation: Here “keys” array is $age and “values” array is $fname. The function
array_combine() will create an array by using the elements from one “keys” array and one
“values” array. So when variable c is called, it will print keys and values.
1.<?php
2.$a=array("A","Cat","Dog","A","Dog");
3.$b=array("A","A","Cat","A","Tiger");
4.$c=array_combine($a,$b);
5.print_r(array_count_values($c));
6.?>
1.<?php
2.$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" =>
"yellow");
3.$a2 = array("e" => "red", "f" => "green", "g" => "blue", "h" =>
"orange");
4.$a3 = array("i" => "orange");
5.$a4 = array_merge($a2, $a3);
6.$result = array_diff($a1, $a4);
7.print_r($result);
8.?>
1.<?php
2.$a1 = array("red", "green");
3.$a2 = array("blue", "yellow");
4.$a3 = array_merge($a1, $a2);
5.$a4 = array("a", "b", "c", "d");
6.$a = array_combine($a4, $a3);
7.print_r($a);
8.?>
a) Array ( [a] => blue [b] => yellow [c] => red [d] => green )
b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )
c) Array ( [0] => red [1] => green [2] => blue [3] => yellow )
d) Array ( [a] => red [b] => green [c] => blue [d] => yellow )
View Answer
Answer: d
Explanation: The function array_merge() merges one or more arrays into one array. If in the
function array_merge(), two or more array elements have the same key, the last one
overrides the others. The function array_combine() will create an array by using the
elements from one “keys” array and one “values” array. The program is the basic combined
application of array_combine() and array_merge().
1.<?php
2.$a = array("a" => "india", "b" => "brazil", "c" => "china");
3.echo array_shift($a);
4.echo "<br>";
5.array_pop($a);
6.print_r($a);
7.?>
a)
india
b)
india
c)
china
d)
china
View Answer
Answer: a
Explanation: The function array_shift() removes the first element from an array, and it
returns the value of the removed element and the function array_pop() deletes the last
element of an array. So “a” => “India”, “c” => “China” will be deleted and “b” => “Brazil” will
be printed.
7. What will be the output of the following PHP code?
1.<?php
2.$a1 = array_fill(1, 4, "hello");
3.$b1 = array_fill(5, 1, "php");
4.$a2 = array_merge($a1, $a2);
5.print_r($a2);
6.echo "<br>";
7.print_r($b1);
8.?>
a)
Array ( [1] => hello [4] => hello [5] => php )
b)
Array ( [1] => hello [2] => hello [3] => hello [4] => hello )
c)
Array ( [1] => hello [2] => hello [3] => hello [4] => hello [5] => php )
Array ( [5] => php )
d)
Array ( [1] => hello [2] => hello [3] => hello [4] => hello )
View Answer
Answer: c
Explanation: Usage of array_fill() and array_merge() functions.
8. What will be the output of the following PHP code?
1.<?php
2.$names = array("Sam", "Bob", "Jack");
3.echo $names[0] . "is the brother of " . $names[1] . " and " .
$names[1] . ".";
4.?>
1.<?php
2.$names = array("Sam", "Bob", "Jack");
3.echo $names[0]."is the brother of ".$names[1]." and ".$names[1].".".
$brother;
4.?>
1.<?php
2. $age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");
3. array_pop($age);
4. print_r(array_change_key_case($age, CASE_UPPER));
5.?>
1.<?php
2.$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" =>
"yellow");
3.$result = array_flip($a1);
4.print_r($result);
5.?>
a) Array ( [red] => red [green] => green [blue] => blue [yellow] => yellow )
b) Array ( [a] => a [b] => b [c] => c [d] => d )
c) Array ( [red] => a [green] => b [blue] => c [yellow] => d )
d) Array ( [a] => red [b] => green [c] => blue [d] => yellow )
View Answer
Answer: c
Explanation: The function array_flip() flips/exchanges all keys with their associated values in
an array. So, in the above program “a” will be flipped with “red”, “b” will be flipped with
“green” and so on.
1.<?php
2.$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" =>
"yellow");
3.$a2 = array("e" => "red","f" => "green", "g" => "blue");
4.$result = array_intersect($a1, $a2);
5.print_r($result);
6.?>
a) Array ( [a] => red [b] => green [c] => blue )
b) Array ( [a] => red [b] => green [c] => blue [d] => yellow )
c) Array ( [e] => red [f] => green [g] => blue )
d) Array ( [a] => red [b] => green [c] => blue [d] => yellow [e] => red [f] => green [g] =>
blue )
View Answer
Answer: a
Explanation: The function array_intersect() compares the values of two (or more) arrays,
and returns the matches. So, in the above program values of a1 and a2 will be compared
and the values present in both the arrays will be the returned.
1.<?php
2.$a = array(12, 5, 2);
3.echo(array_product($a));
4.?>
a) 024
b) 120
c) 010
d) 060
View Answer
Answer: b
Explanation: The array_product() function calculates and returns the product of an array.
1.<?php
2.$a = array("a" => "Jaguar", "b" => "Land Rover",
3."c" => "Audi", "d" => "Maseratti");
4.echo array_search("Audi", $a);
5.?>
a) a
b) b
c) c
d) d
View Answer
Answer: c
Explanation: The array_search() function searches for the element and returns the key of
that element.
1.<?php
2.$city_west = array("NYC", "London");
3.$city_east = array("Mumbai", "Beijing");
4.print_r(array_replace($city_west, $city_east));
5.?>
1.<?php
2.$people = array("Peter", "Susan", "Edmund", "Lucy");
3.echo pos($people);
4.?>
a) Lucy
b) Peter
c) Susan
d) Edmund
View Answer
Answer: b
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.
1.<?php
2.$number = range(0, 5);
3.print_r ($number);
4.?>
a) Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )
b) Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 )
c) Array ( [0] => 5 [1] => 5 [2] => 5 [3] => 5 [4] => 5 [5] => 5 )
d) Array ( [0] => 0 [5] => 5 )
View Answer
Answer: a
Explanation: The range() function creates an array containing a range of elements.
1.<?php
2.$array = array("red", "green");
3.array_push($array, "blue", "yellow");
4.print_r($array);
5.?>
a) Array ( [0] => red [1] => green [2] => blue [3] => yellow )
b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )
c) Array ( [0] => red [1] => green )
d) Array ( [0] => blue [1] => yellow )
View Answer
Answer: a
Explanation: The function array_push() inserts one or more elements to the end of an array.
So, in the above program blue and yellow will be inserted after previous values.
1.<?php
2.$age = array("Harry" => "21", "Ron" => "19", "Malfoy" => "23");
3.ksort($age);
4.foreach($age as $x => $x_value)
5.{
6. echo "Key=" . $x . ", Value=" . $x_value;
7. echo "<br>";
8.}
9.?>
a)
b)
d)
View Answer
Answer: c
1.<?php
2.$cars = array("Volvo", "BMW", "Toyota");
3.echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] .
".";
4.?>
1.<?php
2.$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
3.print_r(array_change_key_case($age, CASE_UPPER));
4.?>
1.<?php
2.$cars = array("Volvo", "BMW", "Toyota", "Honda", "Mercedes", "Opel");
3.print_r(array_chunk($cars, 2));
4.?>
a) Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] =>
Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) )
b) Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] =>
Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) )
c) Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW )
[2] => Array ( [0] => Toyota [1] => Toyota ) )
d) Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] =>
Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) )
View Answer
Answer: d
Explanation: The array_chunk() function splits an array into chunks of new arrays.
1.<?php
2.$fname = array("Peter", "Ben", "Joe");
3.$age = array("35", "37", "43");
4.$c = array_combine($fname, $age);
5.print_r($c);
6.?>
1.<?php
2.$a = array("A", "Cat", "Dog", "A", "Dog");
3.print_r(array_count_values($a));
4.?>
a) Array ( [A] => 2 [Cat] => 1 [Dog] => 2 )
b) Array ( [A] => 2 [Cat] => 2 [Dog] => 1 )
c) Array ( [A] => 1 [Cat] => 1 [Dog] => 2 )
d) Array ( [A] => 2 [Cat] => 1 [Dog] => 1)
View Answer
Answer: a
Explanation: The array_count_values() function counts all the values of an array.
1.<?php
2.$a1 = array("a"=>"red", "b"=>"green", "c"=>"blue", "d"=>"yellow");
3.$a2 = array("e"=>"red", "f"=>"green", "g"=>"blue");
4.$result = array_diff($a1, $a2);
5.print_r($result);
6.?>
1.<?php
2.$a1 = array_fill(3, 4, "blue");
3.$b1 = array_fill(0, 1, "red");
4.print_r($a1);
5.echo "<br>";
6.print_r($b1);
7.?>
a)
b)
Array ( [4] => blue [5] => blue [6] => blue)
c)
Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
Array ()
d)
Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
View Answer
Answer: d
Explanation: The array_fill() function fills an array with values.
8. What will be the output of the following PHP code?
1.<?php
2.$a1 = array("red", "green");
3.$a2 = array("blue", "yellow");
4.print_r(array_merge($a1, $a2));
5.?>
1.<?php
2.$a = array("a"=>"red", "b"=>"green", "c"=>"blue");
3.echo array_shift($a);
4.print_r ($a);
5.?>
a) green
b) red
c) redArray( [c] => green [c] => blue )
d) redArray( [b] => green [c] => blue )
View Answer
Answer: d
Explanation: The array_shift() function removes the first element from an array, and returns
the value of the removed element.
10. What will be the output of the following PHP code?
1.<?php
2.$a = array("red", "green", "blue");
3.array_pop($a);
4.print_r($a);
5.?>
1. <?php
2. $fruits = array ("mango", "apple", "pear", "peach");
3. $fruits = array_flip($fruits);
4. echo ($fruits[0]);
5. ?>
a) mango
b) error
c) peach
d) 0
View Answer
Answer: b
Explanation: As we are flipping the values, $fruits[“mango”] = 0, $fruits[“apple”] = 1 and so
on.
advertisement
1. <?php
2. $fruits = array ("mango", "apple", "peach", "pear");
3. $fruits = asort ($fruits);
4. printr ($fruits);
5. ?>
a) Array ( [1] => apple [0] => mango [2] => peach [3] => pear )
b) Array ( [0] => apple [1] => mango [2] => peach [3] => pear )
c) Error
d) Array ( [1] => apple [0] => mango [3] => peach [2] => pear )
View Answer
Answer: c
Explanation: The program will give an error i.e. uncaught error: call to undefined function
printr(). As the correct function is print_r().
1. <?php
2. $arr = array ("picture1.JPG", "picture2.jpg",
3. "Picture10.jpg", "picture20.jpg");
4. sort($arr);
5. print_r($arr);
6. ?>
a) Array ( [0] => picture1.JPG [1] => Picture10.jpg [2] => picture2.jpg [3] => picture20.jpg )
b) Array ( [0] => picture1.JPG [1] => picture2.jpg [2] => Picture10.jpg [3] => picture20.jpg )
c) Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture2.jpg [3] => picture20.jpg )
d) Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg )
View Answer
Answer: c
Explanation: The function sort() in PHP sorts an indexed array in ascending order. While
sorting, each character is compared with the others and sorted using ASCII values.
1. <?php
2. $face = array ("A", "J", "Q", "K");
3. $number = array ("2","3","4", "5", "6", "7", "8", "9", "10");
4. $cards = array_merge ($face, $number);
5. print_r ($cards);
6. ?>
a) Array ( [0] => A [1] => J [2] => Q [3] => K [4] => 2 [5] => 3 [6] => 4 [7] => 5 [8] => 6 [9] =>
7 [10] => 8 [11] => 9 [12] => 10 )
b) Array ( [0] => A [1] => 2 [2] => J [3] => 3 [4] => Q [5] => 4 [6] => K [7] => 5 [8] => 6 [9] =>
7 [10] => 8 [11] => 9 [12] => 10 )
c) Error
d) Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 10 [9] =>
A [10] => J [11] => Q [12] => K )
View Answer
Answer: a
Explanation: The array_merge() function merges one or more arrays into one array. The
resulting array will begin with the first input array parameter, appending each subsequent
array parameter in the order of appearance.
1. <?php
2. $fruits = array ("apple", "mango", "peach", "pear",
3. "orange");
4. $subset = array_slice ($fruits, 2);
5. print_r ($subset);
6. ?>
1. <?php
2. $fruits = array ("apple", "mango", "peach", "pear",
3. "orange");
4. $subset = array_splice ($fruits, 2);
5. print_r ($fruits);
6. ?>
a) Error
b) Array ( [0] => apple [1] => mango [2] => peach )
c) Array ( [0] => apple [1] => mango )
d) Array ( [0] => pear [1] => orange )
View Answer
Answer: c
Explanation: The array_splice() function removes all elements of an array found within a
specified range.
1. <?php
2. $number = array ("4", "hello", 2);
3. echo (array_sum ($number));
4. ?>
a) 4hello2
b) 4
c) 2
d) 6
View Answer
Answer: d
Explanation: The array_sum() function add all the values of the input array together,
returning the final sum. If a string datatype is found, it’ll be ignored.
1. <?php
2. $array1 = array ("KA", "LA", "CA", "MA", "TA");
3. $array2 = array ("KA", "IA", "CA", "GA", "TA");
4. $inter = array_intersect ($array1, $array2);
5. print_r ($inter);
6. ?>
a) Array ( [0] => KA [1] => LA [2] => CA [3] => MA [4] => TA [5] => IA [6] => GA )
b) Array ( [0] => KA [2] => CA [4] => TA )
c) Array ( [1] => IA [3] => GA )
d) Array ( [1] => LA [3] => MA )
View Answer
Answer: b
1. The practice of separating the user from the true inner workings of an application through
well-known interfaces is known as _________
a) Polymorphism
b) Inheritance
c) Encapsulation
d) Abstraction
View Answer
Answer: c
Explanation: In object-oriented PHP encapsulation is a concept of wrapping up or binding
up the data members and methods in a single module.
2. Which of the following term originates from the Greek language that means “having
multiple forms,” defines OOP’s ability to redefine, a class’s characteristics?
a) Abstraction
b) Polymorphism
c) Inheritance
d) Differential
View Answer
Answer: b
Explanation: The word polymorphism is derived from Greek word poly which means “many”
and morphism which means the property which helps us to assign more than one property.
3. The practice of creating objects based on predefined classes is often referred to as
______________
a) class creation
b) object creation
c) object instantiation
d) class instantiation
View Answer
Answer: d
Explanation: In object-oriented programming, classes are the blueprints of php objects.
Classes do not actually become objects until instantiation is done. When someone
instantiates a class, it creates an instance of it, thus creating the object. In other words,
instantiation is the process of creating an instance of an object in memory.
advertisement
5. Which one of the following can be used to instantiate an object in PHP assuming class
name to be Foo?
a) $obj = new $foo;
b) $obj = new foo;
c) $obj = new foo ();
d) obj = new foo ();
View Answer
Answer: c
Explanation: To create a new object in PHP we can use the new statement to instantiate a
class.
7. Which one of the following is the right way to call a class constant, given that the class is
mathFunction?
a) echo PI;
b) echo mathFunction->PI;
c) echo mathFunction::PI;
d) echo mathFunction=PI;
View Answer
Answer: c
Explanation: The Scope Resolution Operator “::” is a token that allows access to static,
constant, and overridden properties or methods of a class.
a) Only ii)
b) Only iv)
c) i) and ii)
d) iii) and iv)
View Answer
Answer: c
Explanation: In case of public methods, you can forgo explicitly declaring the scope and just
declare the method like you would a function.
10. Which of the following method scopes is/are not supported by PHP?
i) private
ii) friendly
iii) static
iv) abstract
a) Only ii)
b) Only iv)
c) ii) and iv)
d) Only i)
View Answer
Answer: a
1. Which of the following advanced OOP features is/are not supported by PHP?
i) Method overloading
iii) Namespaces
a) i)
b) ii)
c) i) and ii)
d) iii) and iv)
View Answer
Answer: c
Explanation: The advanced OOP features are: Object cloning, Inheritance, Interfaces,
Abstract classes, and Namespaces.
4. The class from which the child class inherits is called ________
i) Child class
ii) Parent class
a) Only i)
b) ii), iii) and iv)
c) Only iii)
d) ii) and iv)
View Answer
Answer: d
Explanation: The class whose properties are inherited by child class is called Base Class or
Parent class.
6. If one intends to create a model that will be assumed by a number of closely related
objects, which class must be used?
a) Normal class
b) Static class
c) Abstract class
d) Interface
View Answer
Answer: c
Explanation: The abstract classes are the classes in which at least one method need to be
abstract. Abstract classes in PHP are declared with the help of keyword abstract. The use
of class abstract are that all base classes implementing abstract class should give
implementation of abstract methods declared in parent class.
7. If your object must inherit behavior from a number of sources you must use a/an
a) Interface
b) Object
c) Abstract class
d) Static class
View Answer
Answer: a
Explanation: An interface in PHP consists of methods that have no implementations, i.e. the
interface methods are abstract methods. The methods in the interfaces must have public
visibility scope. The interfaces are different from classes as the class can inherit from one
class only whereas the class can implement one or more interfaces.
9. Which feature allows us to call more than one method or function of the class in single
instruction?
a) Typecasting
b) Method Including
c) Method adding
d) Method chaining
View Answer
Answer: d
Explanation: When many methods are called in a single instruction in PHP, it is called
method chaining. Following is a basic example of method chaining in php:
$a = new Order();
$a->CreateOrder()->sendOrderEmail()->createShipment();
a) ii)
b) ii) and iii)
c) i), ii), iii) and iv)
d) ii), iii) and iv)
View Answer
Answer: c
Explanation: If a class name and the function name is similar then the function is known as
constructor. Constructor is automatically called when an object will be initialized.
Constructors can accept parameters. Constructors can call class methods or other
functions. Class constructors can call on other constructors.
advertisement
5. Which one of the following functions is used to determine whether a class exists?
a) exist()
b) exist_class()
c) class_exist()
d) __exist()
View Answer
Answer: c
Explanation: The class_exist() function returns true or false according to whether the class
exists within the currently executing script content.
7. Which one of the following keyword is used to inherit our subclass into a superclass?
a) extends
b) implements
c) inherit
d) include
View Answer
Answer: a
Explanation: When we extend a class then the subclass will inherit all the public and
protected methods from the parent class.
The keyword implements are used with interfaces. With inheritance, we use the keyword
extends.
1. <?php
2. class Example
3. {
4. public $name;
5. function Sample()
6. {
7. echo "This is an example";
8. }
9. }
10. ?>
9. Which keyword is used to refer to properties or methods within the class itself?
a) private
b) public
c) protected
d) $this
View Answer
Answer: d
Explanation: In PHP, the self and ‘this’ keyword are used to refer the class members within
the scope of a class itself. The class members can be either variables or functions.
10. Which keyword allows class members (methods and properties) to be used without
needing to instantiate a new instance of the class?
a) protected
b) final
c) static
d) private
View Answer
Answer: c
5. Say you want to report error concerned about fatal run-time, fatal compile-time error and
core error which statement would you use?
a) error_reporting = E_ALL
b) error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
c) error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
d) error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR
View Answer
Answer: d
Explanation: E_ERROR is a fatal run-time error, that can’t be recovered from.
E_COMPILE_ERROR is a fatal error that occurs while the script was being compiled. And
E_CORE_ERROR is a fatal error that occurs during the PHP’s engine initial startup.
7. Which of the following statements causes PHP to disregard repeated error messages
that occur within the same file and on the same line?
a) ignore_repeated_errors
b) ignore_repeat_error
c) repeatedly_ignore_error
d) repeated_error_ignore
View Answer
Answer: a
Explanation: ignore_repeated_errors will not log repeated messages. The repeated errors
must occur in the same file on the same line unless ignore_repeated_source is set to true.
8. Which function initializes the constants necessary for using the openlog(), clodelog(), and
syslog() functions?
a) define_variable()
b) define_log_variable()
c) log_variable()
d) define_syslog_variable()
View Answer
Answer: d
Explanation: If you’re running PHP version 5.2.X or older, you need to execute this function
before using any of the following logging functions.
9. Which logging option’s description is if an error occurs when writing to the syslog, send
output to the system console?
a) LOG_CONS
b) LOG_NDELAY
c) LOG_ODELAY
d) LOG_PERROR
View Answer
Answer: a
Explanation: If there is an error while sending data to the system logger, LOG_CONS will
write directly to the system console.
10. Which function is responsible for sending a custom message to the system log?
a) systemlog()
b) syslog()
c) log_system()
d) sys_log()
View Answer
Answer: b
5. Which one of the following is the right description for the method getMessage()?
a) Returns the message if it is passed to the constructor
b) Returns the message if it is passed to the class
c) Returns the message if it is passed to the file
d) Returns the message if it is passed to the object
View Answer
Answer: a
Explanation: The function getMessage() gets the exception message. It returns the
message if it is passed to the constructor.
6. You can extend the exception base class, but you cannot override any of the preceding
methods because the are declared as__________
a) protected
b) final
c) static
d) private
View Answer
Answer: b
Explanation: Marking a method as final prevents it from being overridden by a subclass.
i) BadFunctionCallException
ii) BadMethodCallException
iii) LogicException
iv) DomainException
a) Only ii)
b) Only iii)
c) i), ii), iii) and iv)
d) Only iv)
View Answer
Answer: c
Explanation: There are total 13 types of predefined exceptions SPL provide access to.
BadFunctionCallException,BadMethodCallExceptio, LogicException, DomainException are
also included in the exceptions.
i) OutOfBoundException
ii) OutOfRangeException
iii) OverflowException
iv) UnderflowException
a) i)
b) i) and iii)
c) i) and ii)
d) i), ii), iii) and iv)
View Answer
Answer: d
1. Which of the following is/are an external data?
i) Cookies
a) Only ii)
b) ii) and iii)
c) Only iii)
d) i), ii), iii) and iv)
View Answer
Answer: d
Explanation: The web applications receives external input. External input/data can be: User
input from a form, Cookies, Web services data, Server variables and, Database query
results.
3. Which one of the following filter is used to filter several variables with the same or
different filters?
a) filter_var_array()
b) filter_var()
c) filter_input
d) filter_input_array
View Answer
Answer: a
Explanation: The function filter_var_array() can get multiple variables and it optionally filters
them. The function is useful for filtering many values without calling filter_var().
1. <?php
2. $num = "123";
3. if (!filter_var($num, FILTER_VALIDATE_INT))
4. echo("Integer is not valid");
5. else
6. echo("Integer is valid");
7. ?>
a) No output is returned
b) Integer is not valid
c) Integer is valid
d) Error
View Answer
Answer: c
Explanation: The function filter_var() can validate and sanitize data. This function filters a
single variable with a specified filter.
1. <?php
2. $var=300;
3. $int_options = array("options"=>array ("min_range"=>0,
"max_range"=>256));
4. if (!filter_var($var, FILTER_VALIDATE_INT, $int_options))
5. echo("Integer is not valid");
6. else
7. echo("Integer is valid");
8. ?>
a) No output is returned
b) Integer is not valid
c) Integer is valid
d) Error
View Answer
Answer: b
Explanation: Since the integer is “300” it is not in the specified range, and the output of the
code above will be: “Integer is not valid”.
8. Which one of the following filter checks if the variable of the specified type exists?
a) filter_has_var
b) filter_var
c) filter_id
d) filter_var_array
View Answer
Answer: a
Explanation: The filter filter_has_var checks if the variable of the specified type exists.
Whereas the function filter_id() returns filter ID of a specified filter name. The function
filter_var() can validate and sanitize data. The function filter_var_array() can get multiple
variables and it optionally filters them.
1. <?php
2. $value = 'car';
3. $result = filter_var($value, FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE);
4. ?>
a) FALSE
b) TRUE
c) NULL
d) ERROR
View Answer
Answer: c
Explanation: There is an undocumented filter flag for FILTER_VALIDATE_BOOLEAN. The
documentation implies that it will return NULL if the value doesn’t match the allowed
true/false values. However this doesn’t happen unless you give it the
FILTER_NULL_ON_FAILURE flag.
1. <?php
2. function convertSpace($string)
3. {
4. return str_replace("_", " ", $string);
5. }
6. $string = "Peter_is_a_great_guy!";
7. echo filter_var($string, FILTER_CALLBACK,
array("options"=>"convertSpace"));
8. ?>
a) Peter_is_a_great_guy!
b) Peterisagreatguy!
c) Peter is a great guy!
d) Error
View Answer
Answer: c
1. PHP has long supported two regular expression implementations known as _______ and
_______
i) Perl
ii) PEAR
iii) Pearl
iv) POSIX
a) i) and ii)
b) ii) and iv)
c) i) and iv)
d) ii) and iii)
View Answer
Answer: c
Explanation: None.
2. Which one of the following regular expression matches any string containing zero or one
p?
a) p+
b) p*
c) P?
d) p#
View Answer
Answer: c
Explanation: None.
advertisement
4. How many functions does PHP offer for searching strings using POSIX style regular
expression?
a) 7
b) 8
c) 9
d) 10
View Answer
Answer: a
Explanation: ereg(), ereg_replace(), eregi(), eregi_replace(), split(), spliti(), and
sql_regcase() are the functions offered.
1. <?php
2. $username = "jasoN";
3. if (ereg("([^a-z])",$username))
4. echo "Username must be all lowercase!";
5. else
6. echo "Username is all lowercase!";
7. ?>
a) Error
b) Username must be all lowercase!
c) Username is all lowercase!
d) No Output is returned
View Answer
Answer: b
Explanation: Because the provided username is not all lowercase, ereg() will not return
FALSE (instead returning the length of the matched string, which PHP will treat as TRUE),
causing the message to output.
1. <?php
2. $text = "this is\tsome text that\nwe might like to parse.";
3. print_r(split("[\n\t]",$text));
4. ?>
9. Which of the following would be a potential match for the Perl-based regular expression
/fo{2,4}/?
i) fol
ii) fool
iii) fooool
iv) fooooool
a) Only i)
b) ii) and iii)
c) i), iii) and iv)
d) i) and iv)
View Answer
Answer: b
Explanation: This matches f followed by two to four occurrences of o.
i) \a
ii) \A
iii) \b
iv) \B
a) Only i)
b) i) and iii)
c) ii), iii) and iv)
d) ii) and iv)
View Answer
Answer: a
1. How many functions does PHP offer for searching and modifying strings using Perl-
compatible regular expressions.
a) 7
b) 8
c) 9
d) 10
View Answer
Answer: b
Explanation: The functions are preg_filter(), preg_grep(), preg_match(), preg_match_all(),
preg_quote(), preg_replace(), preg_replace_callback(), and preg_split().
1. <?php
2. $foods = array("pasta", "steak", "fish", "potatoes");
3. $food = preg_grep("/^s/", $foods);
4. print_r($food);
5. ?>
a) Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes )
b) Array ( [3] => potatoes )
c) Array ( [1] => steak )
d) Array ( [0] => potatoes )
View Answer
Answer: c
Explanation: This function is used to search an array for foods beginning with s.
advertisement
3. Say we have two compare two strings which of the following function/functions can you
use?
i) strcmp()
ii) strcasecmp()
iii) strspn()
iv) strcspn()
a) i) and ii)
b) iii) and iv)
c) only i)
d) i), ii), iii) and iv)
View Answer
Answer: d
Explanation: All of the functions mentioned above can be used to compare strings in some
or the other way.
4. Which one of the following functions will convert a string to all uppercase?
a) strtoupper()
b) uppercase()
c) str_uppercase()
d) struppercase()
View Answer
Answer: a
Explanation: Its prototype follows string strtoupper(string str).
1. <?php
2. $title = "O'malley wins the heavyweight championship!";
3. echo ucwords($title);
4. ?>
1. <?php
2. echo str_pad("Salad", 5)." is good.";
3. ?>
a) SaladSaladSaladSaladSalad is good
b) is good SaladSaladSaladSaladSalad
Salad c) is good
is good d) Salad
View Answer
Answer: d
Explanation: The str_pad() function pads a string with a specified number of characters.
7. Which one of the following functions can be used to concatenate array elements to form
a single delimited string?
a) explode()
b) implode()
c) concat()
d) concatenate()
View Answer
Answer: b
Explanation: None.
8. Which one of the following functions finds the last occurrence of a string, returning its
numerical position?
a) strlastpos()
b) strpos()
c) strlast()
d) strrpos()
View Answer
Answer: d
Explanation: None.
1. <?php
2. $author = "nachiketh@example.com";
3. $author = str_replace("a","@",$author);
4. echo "Contact the author of this article at $author.";
5. ?>
1. <?php
2. $url = "nachiketh@example.com";
3. echo ltrim(strstr($url, "@"),"@");
4. ?>
a) nachiketh@example.com
b) nachiketh
c) nachiketh@
d) example.com
View Answer
Answer: d
2. Which one of the following PHP function is used to determine a file’s last access time?
a) fileltime()
b) filectime()
c) fileatime()
d) filetime()
View Answer
Answer: c
Explanation: The fileatime() function returns a file’s last access time in Unix timestamp
format or FALSE on error.
3. Which one of the following function is capable of reading a file into an array?
a) file()
b) arrfile()
c) arr_file()
d) file_arr()
View Answer
Answer: a
Explanation: The function file() will read the entire file into an array.
advertisement
4. Which one of the following function is capable of reading a file into a string variable?
a) file_contents()
b) file_get_contents()
c) file_content()
d) file_get_content()
View Answer
Answer: b
Explanation: The function file_get_contents() reads a file into a string. This is the preferred
way to read the contents of a file into a string as it will use memory mapping techniques.
5. Which one of the following function is capable of reading a specific number of characters
from a file?
a) fgets()
b) fget()
c) fileget()
d) filegets()
View Answer
Answer: a
Explanation: The function fgets() will return a line from an open file. This stops returning on
a new line, at the specified length, or at EOF, whichever comes first. Its prototype is string
fgets(resource handle [, int length]). If the optional length parameter is omitted, 1024
character is assumed.
6. Which one of the following function operates similarly to fgets(), except that it also strips
any HTML and PHP tags form the input?
a) fgetsh()
b) fgetsp()
c) fgetsa()
d) fgetss()
View Answer
Answer: d
Explanation: The function fgetss() returns a line, with HTML and PHP tags removed, from
an open file. This function operates similarly to fgets(), except that it also strips any HTML
and PHP tags form the input.
7. Which one of the following function outputs the contents of a string variable to the
specified resource?
a) filewrite()
b) fwrite()
c) filewrites()
d) fwrites()
View Answer
Answer: b
Explanation: The function fwrite() writes to an open file. This will stop at the end of the file or
when it reaches the specified length, whichever comes first.
8. Which function sets the file filename last-modified and last-accessed times?
a) sets()
b) set()
c) touch()
1. Which directive determines whether PHP scripts on the server can accept file uploads?
a) file_uploads
b) file_upload
c) file_input
d) file_intake
View Answer
Answer: a
Explanation: With PHP, it is easy to upload files to the server. We need to ensure that PHP
is configured to allow file uploads. In the “php.ini” file, search for the file_uploads directive,
and set it to On. By default, its value is on.
2. Which of the following directive determines the maximum amount of time that a PHP
script will spend attempting to parse input before registering a fatal error?
a) max_take_time
b) max_intake_time
c) max_input_time
d) max_parse_time
View Answer
Answer: c
Explanation: This is relevant because particularly large files can take some time to upload,
eclipsing the time set by this directive.
6. Which directive sets a maximum allowable amount of memory in megabytes that a script
can allow?
a) max_size
b) post_max_size
c) max_memory_limit
d) memory_limit
View Answer
Answer: d
Explanation: Its default value is 16M.
7. If you want to temporarily store uploaded files in the /tmp/phpuploads/ directory, which
one of the following statement will you use?
a) upload_tmp_dir “/tmp/phpuploads/ directory”
b) upload_dir “/tmp/phpuploads/ directory”
c) upload_temp_dir “/tmp/phpuploads/ directory”
d) upload_temp_director “/tmp/phpuploads/ directory”
View Answer
Answer: a
Explanation: Anyone can temporarily store uploaded files on the given directory. One
cannot change upload_tmp_dir at the runtime. By the time a script runs, the upload process
has already occurred.
8. Which superglobal stores a variety of information pertinent to a file uploaded to the server
via a PHP script?
a) $_FILE Array
b) $_FILES Array
c) $_FILES_UPLOADED Array
d) $_FILE_UPLOADED Array
View Answer
Answer: b
Explanation: The superglobal $_FILES is a two-dimensional associative global array of
items which are being uploaded by via HTTP POST method and holds the attributes of files.
View Answer
Answer: c
Explanation: The function touch() will set the access and modification time of the specified
file. Syntax is touch(filename, time, atime).
9. Which function is useful when you want to output the executed command result?
a) out_cmm()
b) out_system()
c) cmm()
d) system()
View Answer
Answer: d
Explanation: The function system() in PHP is same as the C version of the function as in
that it executes the given command and outputs the result. This function also tries to
automatically flush the web server’s output buffer after each line of output if PHP is running
as a server module.
10. Which one of the following function reads a directory into an Array?
a) scandir()
b) readdir()
c) scandirectory()
d) readdirectory()
View Answer
Answer: a
1. What is the full form of DNS?
a) Digital Network System
b) Domain Network System
c) Digital Name Systmem
d) Domain Name System
View Answer
Answer: d
Explanation: DNS stands for domain name system. It is the way that internet domain names
are located and translated into internet protocol (IP) addresses. For example, if someone
types abc.com into the web browser, a server behind the scenes will map that name to the
IP address 206.16.49.139.
2. Which one of the following function checks for the existence of DNS records?
a) checkdns()
b) checkdnsr()
c) checkdnsrr()
d) checkdnsa()
View Answer
Answer: c
Explanation: The function checkdnsrr() is used to check DNS records for type
corresponding to host. DNS records are checked based on the supplied host value and
optional DNS resource record type, returning TRUE if any records are located and FALSE
otherwise.
3. Which one of the following function is used to return an array consisting of various DNS
resource records pertinent to a specific domain?
a) dns_get_record()
b) dns_record()
c) dnsrr_get_record()
d) dnsrr_record()
View Answer
Answer: a
Explanation: The function dns_get_record() is used to get the DNS resource records
associated with the specified hostname. This function is used to return an array consisting
of various DNS resource records pertinent to a specific domain.
advertisement
4. Which one of the following function is used to retrieve the MX records for the domain
specified by hostname?
a) getmx()
b) retrieve_mx()
c) getmxrr()
d) retrieve_mxrr()
View Answer
Answer: c
Explanation: The function getmxrr() returns the MX records for the specified internet host
name. This function is used to retrieve the MX records for the domain specified by
hostname.
5. What is the default port number of HTTPs?
a) 70
b) 80
c) 90
d) 100
View Answer
Answer: b
Explanation: By default, The port number HTTP uses is port 80 and HTTPS uses port 443,
but a URL like http://www.abc.com:8080/path/ specifies that the web browser connects
instead to port 8080 of the HTTP servers.
6. Which one of the following function returns the port number of a specified service?
a) getportname()
b) getservername()
c) getserverbyname()
d) getservbyname()
View Answer
Answer: d
Explanation: The function fgetservbyname() returns the port number for a given Internet
service and protocol. Example-getservbyname(“http”,”tcp”) will return 80.
7. Which one of the following statements can be used to establish port 80 connection with
www.nachi.com?
a) fsockopen(“www.nachi.com”, 80);
b) sockopen(80,”www.nachi.com”);
c) fsockopen(80,”www.nachi.com”);
d) sockopen(“www.nachi.com”, 80);
View Answer
Answer: a
Explanation: The fsockopen() function establishes a connection to the resource designated
by target on port.
8. Which one of the following function is used to send an email using PHP script?
a) mail_send()
b) send_mail()
c) mailrr()
d) mail()
View Answer
Answer: d
Explanation: The function mail() allows you to send emails directly from a script. Using
mail(string to, string subject, string message), you can send any mail.
9. How many configuration directives pertinent to PHP’s mail function are available?
a) 4
b) 5
c) 6
d) 7
View Answer
Answer: b
Explanation: They are- SMTP, sendmail_from, sendmail_path, smtp_port,
mail.force_extra_parameters.
10. Which of the following statements is used to add an attachment to the mail?
a) $mimemail->attachment(‘attachment.pdf’);
b) $mimemail=>attachment(‘attachment.pdf’);
c) $mimemail->addAttachment(‘attachment.pdf’);
d) $mimemail=>addAttachment(‘attachment.pdf’);
View Answer
Answer: c
1. Which one of the following is the very first task executed by a session enabled page?
a) Delete the previous session
b) Start a new session
c) Check whether a valid session exists
d) Handle the session
View Answer
Answer: c
Explanation: The session variables are set with the PHP global variable which is
$_SESSION. The very first task executed by a session enabled page is Check whether a
valid session exists.
6. If the directive session.cookie_lifetime is set to 3600, the cookie will live until
____________
a) 3600 sec
b) 3600 min
c) 3600 hrs
d) the browser is restarted
View Answer
Answer: a
Explanation: The lifetime is specified in seconds, so if the cookie should live 1 hour, this
directive should be set to 3600.
7. Neglecting to set which of the following cookie will result in the cookie’s domain being set
to the host name of the server which generated it.
a) session.domain
b) session.path
c) session.cookie_path
d) session.cookie_domain
View Answer
Answer: d
Explanation: The directive session.cookie_domain determines the domain for which the
cookie is valid.
8. What is the default number of seconds that cached session pages are made available
before the new pages are created?
a) 360
b) 180
c) 3600
d) 1800
View Answer
Answer: b
Explanation: The directive which determines this is session.cache_expire.
9. What is the default time(in seconds) for which session data is considered valid?
a) 1800
b) 3600
c) 1440
d) 1540
View Answer
Answer: c
Explanation: The session.gc_maxlifetime directive determines this duration. It can be set to
any required value.
1. Which function is used to erase all session variables stored in the current session?
a) session_destroy()
b) session_change()
c) session_remove()
d) session_unset()
View Answer
Answer: d
Explanation: The function session_unset() frees all session variables that is currently
registered. This will not completely remove the session from the storage mechanism. If you
want to completely destroy the session, you need to use the function session_destroy().
3. Which one of the following statements should you use to set the session username to
Nachi?
a) $SESSION[‘username’] = “Nachi”;
b) $_SESSION[‘username’] = “Nachi”;
c) session_start(“nachi”);
d) $SESSION_START[“username”] = “Nachi”;
View Answer
Answer: b
Explanation: You need to refer the session variable ‘username’ in the context of the
$_SESSION superglobal.
advertisement
4. What will be the output of the following PHP code? (Say your previous session username
was nachi.)
1. unset($_SESSION['username']);
2. printf("Username now set to: %s", $_SESSION['username']);
6. Which parameter determines whether the old session file will also be deleted when the
session ID is regenerated?
a) delete_old_file
b) delete_old_session
c) delete_old_session_file
d) delete_session_file
View Answer
Answer: b
Explanation: The parameter delete_old_session determines whether the old session file will
also be deleted when the session ID is regenerated.
8. Which function is used to transform PHP’s session-handler behavior into that defined by
your custom handler?
a) session_set_save()
b) session_set_save_handler()
c) Session_handler()
d) session_save_handler()
View Answer
Answer: b
Explanation: The function session_set_save_handler() is used to set the user-level session
storage functions which are used for storing and retrieving data associated with a session.
1. Which one of the following statements should be used to disable just the fopen(), and
file() functions?
a) disable_functions = fopen(), file()
b) disable_functions = fopen, file
c) functions_disable = fopen(), file()
d) functions_disable = fopen, file
View Answer
Answer: b
Explanation: You can set disable_functions equal to a comma-delimited list of function
names that you want to disable.
2. Which one of the following statements should be used to disable the use of two classes
administrator and janitor?
a) disable_classes = “administrator, janitor”
b) disable_classes = class administrator, class janitor
c) disable_classes = class “administrator”, class “janitor”
d) disable_class = class “administrator”, class “janitor”
View Answer
Answer: a
Explanation: There may be classes inside the libraries that you’d rather not make available.
You can prevent the use of these classes with the disable_classes directive.
3. What is the default value of max_execution_time directive? This directive specifies how
many seconds a script can execute before being terminated.
a) 10
b) 20
c) 30
d) 40
View Answer
Answer: c
Explanation: This can be useful to prevent users’ scripts from consuming too much CPU
time. If max_execution_time is set to 0, no time limit will be set.
advertisement
4. The memory_limit is only applicable if ________ is enabled when you configure PHP.
a) –enable-limit
b) -enable-memory-limit
c) –enable-memory-limit
d) -memory-limit
View Answer
Answer: c
Explanation: This directive specifies, in megabytes, how much memory a script can use.
Default value: 128M.
5. Suppose all web material is located within the directory /home/www. To prevent users
from viewing and manipulating files such as /etc/password, which one of the following
statements should you use?
a) open_dir = “/home/www/”
b) open_dir = /home/www/
c) open_basedir = /home/www/
d) open_basedir = “/home/www/”
View Answer
Answer: d
Explanation: We can use open_basedir statement to define the paths from which we can
access files using functions like fopen() and gzopen(). It is used to prevent users from
viewing and manipulating files such as /etc/password.
6. Which Apache directive outputs Apache’s server version, server name, port and compile-
in modules?
a) ServerSignature
b) ServerName
c) ServerDetails
d) ServerInfo
View Answer
Answer: a
Explanation: It is capable of displaying output like: Apache/2.2.11 (Ubuntu) Server at
localhost Port 80.
7. Which directive determines which degree of server details is provided if the
ServerSignature directive is enabled?
a) ServerAddons
b) ServerExtra
c) ServerTokens
d) ServerDetails
View Answer
Answer: c
Explanation: Six options are available: Full, Major, Minimal, Minior, OS, and Prod. If it is set
to Full ‘Apache/2.2.11 (Ubuntu) PHP/5.3.2 Server’ will be displayed.
8. Which directive should we disable to obscure the fact that PHP is being used on our
server?
a) show_php
b) expose_php
c) print_php
d) info_php
View Answer
Answer: b
Explanation: Using the expose_php directive we can prevent PHP version details from
being appended on our web server signature. When expose_php is disabled, the server
signature will look like: Apache/2.2.11 (Ubuntu) Server.
9. Say I want to change the extension of a PHP file, which of the following statements
should I edit to change from .php to .html in the httpd.conf file?
a) AddType application/x-httpd-php .php
b) AddType application/x-httpd-php .asp
c) AddType application/x-httpd-asp .php
d) AddType application/x-httpd-asp .asp
View Answer
Answer: a
Explanation: Just change the .php to .html and your extension will change. This is used for
security purpose.
10. The developers of PHP deprecated the safe mode feature as of which PHP version.
a) PHP 5.1.0
b) PHP 5.2.0
c) PHP 5.3.0
d) PHP 5.3.1
View Answer
Answer: c
1. <?php
2. echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');
3. ?>
a) TRUE
b) FALSE
c) Valid
d) Invalid
View Answer
Answer: d
Explanation: The function checkdate() is used to validate a Gregorian date. In the program,
April has 30 days and the above date is 31 therefore Invalid is returned.
advertisement
2. The date() function returns ___ representation of the current date and/or time.
a) Integer
b) String
c) Boolean
d) Float
View Answer
Answer: b
Explanation: The function date() is used to format a local date and time, and it will return the
formatted date string. The syntax of this function is string date(string format [, int
timestamp]).
3. Which one of the following format parameter can be used to identify timezone?
a) T
b) N
c) E
d) I
View Answer
Answer: c
Explanation: When the format is E the time zone is identified and returned, for example,
America/New York. N denotes ISO-8601 numeric representation of the day of the week, T
denotes time zone abbreviation, I denotes whether or not the date is in daylight saving time.
5. What will be the output of the following code? (If say date is 22/06/2013.)
1. <?php
2. echo "Today is ".date("F d, Y");
3. ?>
6. Which one of the following function is useful for producing a timestamp based on a given
date and time?
a) time()
b) mktime()
c) mrtime()
d) mtime()
View Answer
Answer: b
Explanation: The function mktime() returns the Unix timestamp for a date. This function is
same as gmmktime() except that the passed parameters represents a date not a GMT date.
7. Which function displays the web page’s most recent modification date?
a) lastmod()
b) getlastmod()
c) last_mod()
d) get_last_mod()
View Answer
Answer: b
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.
8. What will be the output of the following PHP code? (If say date is 22/06/2013.)
1. <?php
2. printf( date("t") );
3. ?>
a) 30
b) 22
c) JUNE
d) 2013
View Answer
Answer: a
Explanation: The t parameter is used to determine the number of days in the current month.
9. Suppose you want to calculate the date 45 days from the present date which one of the
following statement will you use?
a) totime(“+45”)
b) totime(“+45 days”)
c) strtotime(“+45 days”)
d) strtotime(“-45 days”)
View Answer
Answer: c
Explanation: The strtotime() function and GNU date syntax is used to calculating the date x
days from the present date.
10. To create an object and set the date to JUNE 22, 2013, which one of the following
statement should be executed?
a) $date = Date(“22 JUNE 2013”)
b) $date = new Date(“JUNE 22 2013”)
c) $date = DateTime(“22 JUNE 2013”)
d) $date = new DateTime(“22 JUNE 2013”)
View Answer
Answer: d
4. Which of the following is the right way to use the DateTime class?
a) $date = get_Class(DateTime);
b) $date = class DateTime;
c) $date = new DateTime();
d) $date = new class DateTime();
View Answer
Answer: c
Explanation: The way you use the DateTime class is like any other class: instantiate an
object, and store it in a variable.
5. What will be the output of the following PHP code if date is 24/02/2008?
1. <?php
2. $date = new DateTime();
3. echo $date->format('l,F,js,Y');
4. ?>
6. Which of the following statements can be used to set the time zone in individual scripts?
a) date_set_timezone(‘Europe/London’);
b) date_default_timezone_set(‘Europe/London’);
c) date_set_default_timezone(‘Europe/London’);
d) date_default_timezone(‘Europe/London’);
View Answer
Answer: b
Explanation: The function date_default_timezone_set is used to set the default time zone
used by all date/time functions in a script. You can also use ini_set(‘date.timezone’,
‘Europe/London’);
i) listAbbreviations()
ii) getName()
iii) getOffset()
iv) listIdentifiers()
a) Only i)
b) Only ii)
c) i) and iv)
d) iii) and iv)
View Answer
Answer: c
Explanation: listAbbreviations() and listIdentifiers() are static methods.
i) _construct()
ii) getName()
iii) getOffset()
iv) getTransitions()
a) Only i)
b) Only ii)
c) i), ii), iii) and iv)
d) iii) and iv)
View Answer
Answer: c
Explanation: All of the given methods are non static.
9. Which of the following statements can be used to add two months to the existing date?
a) $date->modify(‘+2 months’);
b) $date = modify(‘+2 months’);
c) $date = modify(‘2+ months’);
d) $date->modify(‘2+ months’);
View Answer
Answer: a
Explanation: To change the date stored by a DateTime object after it has been created, you
use DateTime::modify() with a natural language expression.
10. Which method enables you to calculate whether daylight saving time is in force at a
specific date and time?
a) getOffset()
b) getTranitions()
c) ISODate()
d) savingTime()
View Answer
Answer: b
1. Which two predefined variables are used to retrieve information from forms?
a) $GET & $SET
b) $_GET & $_SET
c) $__GET & $__SET
d) GET & SET
View Answer
Answer: b
Explanation: The global variables $_GET is used to collect form data after submitting an
HTML form with the method=”get”. The variable $_SET is also used to retrieve information
from forms.
2. The attack which involves the insertion of malicious code into a page frequented by other
users is known as _______________
a) basic sql injection
b) advanced sql injection
c) cross-site scripting
d) scripting
View Answer
Answer: c
Explanation: The cross-site scripting attack is among one of the top five security attacks
carried out across the Internet. It is also known as XSS, this attack is a type of code
injection attack which is made possible by incorrectly validating user data, which usually
gets inserted into the page through a web form or using an altered hyperlink.
3. When you use the $_GET variable to collect data, the data is visible to ___________
a) none
b) only you
c) everyone
d) selected few
View Answer
Answer: c
Explanation: The information sent from a form with the method GET is visible to everyone
i.e. all variable names and values are displayed in the URL.
advertisement
4. When you use the $_POST variable to collect data, the data is visible to ___________
a) none
b) only you
c) everyone
d) selected few
View Answer
Answer: b
Explanation: The information sent from a form with the method POST is invisible to others
i.e. all names/values are embedded within the body of the HTTP request.
5. Which variable is used to collect form data sent with both the GET and POST methods?
a) $BOTH
b) $_BOTH
c) $REQUEST
d) $_REQUEST
View Answer
Answer: d
Explanation: In PHP the global variable $_REQUEST is used to collect data after submitting
an HTML form.
6. Which one of the following should not be used while sending passwords or other
sensitive information?
a) GET
b) POST
c) REQUEST
d) NEXT
View Answer
Answer: a
Explanation: The information sent from a form with the method GET is visible to everyone
i.e. all variable names and values are displayed in the URL. So, it should not be used while
sending passwords or other sensitive information.
7. Which function is used to remove all HTML tags from a string passed to a form?
a) remove_tags()
b) strip_tags()
c) tags_strip()
d) tags_remove()
View Answer
Answer: b
Explanation: The function strip_tags() is used to strip a string from HTML, XML, and PHP
tags.
8. What will be the value of the variable $input in the following PHP code?
1. <?php
2. $input = "Swapna<td>Lawrence</td>you are really<i>pretty</i>!";
3. $input = strip_tags($input,"<i></i>");
4. echo $input;
5. ?>
10. How many validation filters like FILTER_VALIDATE_EMAIL are currently available?
a) 5
b) 6
c) 7
d) 8
View Answer
Answer: c
i) $_SERVER['PHP_AUTH_USER'].
ii) $_SERVER['PHP_AUTH_USERS'].
iii) $_SERVER['PHP_AUTH_PU'].
iv) $_SERVER['PHP_AUTH_PW'].
a) i) and ii)
b) ii) and iv)
c) i) and iv)
d) ii) and iii)
View Answer
Answer: c
Explanation: $_SERVER[‘PHP_AUTH_USER’] and $_SERVER[‘PHP_AUTH_PW’] store
the username and password values, respectively.
advertisement
3. Which of the following PHP function is commonly used when handling authentication via
PHP?
i) header()
ii) footer()
iii) inset()
iv) isset()
a) i) and iv)
b) ii) and iv)
c) ii) and iii)
d) i) and iii)
View Answer
Answer: a
Explanation: The function isset () is used to check whether a variable is set or not and the
function header() sends a raw HTTP header to a client.
6. In which authentication method does changing the username or password can be done
only by entering the code and making the manual adjustment.
a) Hard-coding a login pair directly into the script
b) File-based authentication
c) Data-based authentication
d) PEAR’S HTTP authentication
View Answer
Answer: a
Explanation: The simplest way to restrict resource access is by hard-coding the username
and password directly into the script. In this authentication method, changing the username
or password can be done only by entering the code and making the manual adjustment.
This is one of the drawbacks of hard-coding a login pair directly into the script.
7. The authenticationFile.txt, the file which stores username and password should be stored
___ the server document root.
a) Inside
b) Outside
c) Within
d) None of the mentioned
View Answer
Answer: b
Explanation: If it is not stored outside, the attacker could discover the file through brute
force guessing.
8. Which function is used to split a string into a series of substrings, with each string
boundary is determined by a specific separator?
a) break()
b) divide()
c) explode()
d) md5()
View Answer
Answer: c
Explanation: Although they are a similar function, you should use explode() instead of
split(). In fact split() function has been deprecated altogether.
i) small list
a) i) and iv)
b) i) and iii)
c) ii) and iii)
d) ii) and iv)
View Answer
Answer: c
Explanation: Such requirements are better satisfied by implementing a database based
solution.
10. Which is the most powerful authentication method among the four?
a) Hard-coding a login pair directly into the script
b) File-based authentication
c) Data-based authentication
d) PEAR’S HTTP authentication
View Answer
Answer: c
1. <?php
2. $number = array(0,1,two,three,four,5);
3. $num = preg_grep("/[0-5]/", $number);
4. print_r($num);
5. ?>
2. What will be the output if we replace the line $num = preg_grep(“/[0-5]/”, $number); with
$num = preg_grep(“/[0-5]/”, $number, PREG_GREP_INVERT);?
a) Array([0]=>0 [1]=>1 [2]=>two [3]=>three [4]=>four [5]=>5)
b) Array([2]=>two [3]=>three [4]=>four)
c) Array([1]=> 1)
d) Array([0]=>0 [5]=>5)
View Answer
Answer: b
Explanation: When we include PREG_GREP_INVERT, this will invert our data, so instead
of outputting numbers it will output our non-numeric values.
5. Which one of the following preg PHP function is used to do a find and replace on a string
or an array?
a) preg_replace()
b) preg_find()
c) preg_find_replace()
d) preg_findre()
View Answer
Answer: a
Explanation: In preg_replace() function, after the replacement has occurred, the modified
string will be returned and if no matches are found, the string will remain unchanged.
1. <?php
2. $str = "Hello! My name is Cameron Fox. Coffee?";
3. $find = array('/is/','/coffee/');
4. $replace = array('/was/','/tea/');
5. echo preg_replace ($find, $replace, $str);
6. ?>
7. Which one of the following preg PHP functions is used to take a string, and put it in an
array?
a) preg_destroy()
b) preg_split()
c) preg_unchain()
d) preg_divide()
View Answer
Answer: b
Explanation: The string is broken up into different values in the array based upon your input.
1. <?php
2. $line = "You like dogs. I hate dogs. We should marry.";
3. $sen = preg_split('/\./', $line);
4. print_r($sen);
5. ?>
1. Which one of the following databases has PHP supported almost since the beginning?
a) Oracle Database
b) SQL
c) SQL+
d) MySQL
View Answer
Answer: d
Explanation: We can connect, insert, update, delete and retrieve data from the databases
with the help of PHP and MySQL is the most popular database system used with PHP.
3. Which one of the following lines need to be uncommented or added in the php.ini file so
as to enable mysqli extension?
a) extension=php_mysqli.dll
b) extension=mysql.dll
c) extension=php_mysqli.dl
d) extension=mysqli.dl
View Answer
Answer: a
Explanation: Also make sure that extension_dir directive points to the appropriate directory.
advertisement
4. In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?
a) PHP 5.0
b) PHP 5.1
c) PHP 5.2
d) PHP 5.3
View Answer
Answer: d
Explanation: PHP required that MySQL client library be installed on the server from which
PHP was communicating with MySQL, whether the MySQL server also happened to reside
locally or elsewhere. PHP 5.3 removes this problem by introducing MySQL Native Driver.
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
7.Which one of the following statements can be used to select the database?
a) $mysqli=select_db('databasename');
b) mysqli=select_db('databasename');
c) mysqli->select_db('databasename');
d) $mysqli->select_db('databasename');
View Answer
Answer: d
Explanation: $mysqli->select_db(‘databasename’); can be used to select the database.
8. Which one of the following methods can be used to diagnose and display information
about a MySQL connection error?
a) connect_errno()
b) connect_error()
c) mysqli_connect_errno()
d) mysqli_connect_error()
View Answer
Answer: c
Explanation: The mysqli extension includes a few features that can be used to capture error
messages or alternatively you can use exceptions.
9. Which method returns the error code generated from the execution of the last MySQL
function?
a) errno()
b) errnumber()
c) errorno()
d) errornumber()
View Answer
Answer: a
Explanation: Error numbers are often used in lieu of natural-language message to ease
software internationalization efforts and allow for customization of error messages.
10. If there is no error, then what will the error() method return?
a) TRUE
b) FALSE
c) Empty String
d) 0
View Answer
Answer: c
2. Which one of the following methods is responsible for sending the query to the database?
a) query()
b) send_query()
c) sendquery()
d) mysqli_query()
View Answer
Answer: d
Explanation: The method mysqli_query() is responsible for sending the query to the
database. Query() method was previously used in older versions of PHP.
advertisement
3. Which one of the following methods recuperates any memory consumed by a result set?
a) destroy()
b) mysqli_free_result()
c) alloc()
d) free()
View Answer
Answer: b
Explanation: The function mysqli_free_result() is used to free the memory which is
associated with the result. Once this method is executed, the result set is no longer
available. Free() function was used in the previous version of PHP.
4. Which of the methods are used to manage result sets using both associative and indexed
arrays?
a) get_array() and get_row()
b) get_array() and get_column()
c) fetch_array() and fetch_row()
d) mysqli_fetch_array() and mysqli_fetch_row()
View Answer
Answer: d
Explanation: The method mysqli_fetch_array() is used to fetch a result row as an
associative array or a numeric array.
And the function mysqli_fetch_row() is used to fetche one row from a result-set and returns
it as an enumerated array.
The method fetch_array() and fetch_row() were used in the previous version of PHP.
5. Which one of the following method is used to retrieve the number of rows affected by an
INSERT, UPDATE, or DELETE query?
a) num_rows()
b) affected_rows()
c) changed_rows()
d) mysqli_affected_rows()
View Answer
Answer: d
Explanation: The method mysqli_num_rows() is only useful for determining the number of
rows retrieved by a SELECT query. But to retrieve the number of rows affected by INSERT,
UPDATE, or DELETE query, use mysqli_affected_rows(). Num_rows() and affected_rows()
were used in previous version of PHP.
7. Which of the following methods is used to execute the statement after the parameters
have been bound?
a) bind_param()
b) bind_result()
c) bound_param()
d) bound_result()
View Answer
Answer: a
Explanation: Once the statement has been prepared, it needs to be executed. Exactly when
it’s executed depends upon whether you want to work with bound parameters or bound
results. In the case of bound parameters, you’d execute the statement after the parameters
have been bound with the bind_param() method.
9. Which method retrieves each row from the prepared statement result and assigns the
fields to the bound results?
a) get_row()
b) fetch_row()
c) fetch()
d) mysqli_fetch_row()
View Answer
Answer: d
Explanation: The function mysqli_fetch_row() is used to fetche row from a result-set and
returns it as an enumerated array.
Its syntax is mysqli_fetch_row(result);
2. Fill in the blank with the best option. An Object is a/an ________ of a class.
a) type
b) prototype
c) instance
d) object
View Answer
Answer: c
Explanation: An object is said to be an instance of its class. It is of the type defined by the
class.
4. Which version of PHP introduced the visibility keywords i.e public, private, and protected?
a) PHP 4
b) PHP 5
c) PHP 5.1
d) PHP 5.3
View Answer
Answer: b
Explanation: In PHP 4, all properties were declared with var keyword, which is identical in
effect to using public. For the sake of backward compatibility, PHP 5 accepts var in place of
public for properties.
6. Code that uses a class, function, or method is often described as the ____________
a) client code
b) user code
c) object code
d) class code
View Answer
Answer: a
Explanation: Code that uses a class, function, or method is often described as the class’s,
function, or method client or as client code.
8. If you omit the visibility keyword in your method declaration, by default the method will be
declared as ____________
a) public
b) private
c) protected
d) friendly
View Answer
Answer: a
Explanation: By declaring a method public, you ensure that it can be invoked from outside
of the current object.
9. Which function is used to determine whether the variable’s value is either TRUE or
FALSE?
a) boolean()
b) is_boolean()
c) bool()
d) is_bool()
View Answer
Answer: d
Explanation: None.
1.<?php
2. class ShopProductWriter
3. {
4. public function write( $shopProduct )
5. {
6. $str = "{$shopProduct->title}: " .$shopProduct-
>getProducer() ." ({$shopProduct->price})\n";
7. print $str;
8. }
9. }
10. $product1 = new ShopProduct( "My Antonia", "Willa",
"Cather", 5.99 );
11. $writer = new ShopProductWriter();
12. $writer->write( $product1 );
13. ?>
a) Error
b) Cather: Willa My Antonia (5.99)
c) Willa: Cather My Antonia (5.99)
d) My Antonia: Willa Cather (5.99)
View Answer
Answer: d
2. Inheritance is the means by which one or more classes can be derived from a/an
___________ class.
a) base
b) abstract
c) null
d) predefined
View Answer
Answer: a
Explanation: A class that inherits from another is said to be a subclass of it. This
relationship is often described in terms of parents and children. A child class is derived from
and inherits characteristics from the parent.
advertisement
1.<?php
2.class MyClass
3.{
4.}
5.
6.class NotMyClass
7.{
8.}
9.$a = new MyClass;
10.
11. var_dump($a instanceof MyClass);
12. var_dump($a instanceof NotMyClass);
13. ?>
a)
bool(true)
bool(true)
b)
bool(false)
bool(false)
c)
bool(true)
bool(false)
d)
bool(false)
bool(true)
View Answer
Answer: c
Explanation: instanceof is used to determine whether a PHP variable is an instantiated
object of a certain class.
4. What will be the output of the following PHP code?
1.<?php
2.class ParentClass
3.{
4.}
5.
6.class MyClass extends ParentClass
7.{
8.}
9.
10. $a = new MyClass;
11.
12. var_dump($a instanceof MyClass);
13. var_dump($a instanceof ParentClass);
14. ?>
a)
bool(false)
bool(false)
b)
bool(true)
bool(true)
c)
bool(false)
bool(true)
d)
bool(true)
bool(false)
View Answer
Answer: b
Explanation: instanceof can also be used to determine whether a variable is an instantiated
object of a class that inherits from a parent class.
5. What will be the output of the following PHP code?
1.<?php
2.class MyClass
3.{
4.}
5.
6.$a = new MyClass;
7.var_dump(!($a instanceof stdClass));
8.?>
a) bool(true)
b) bool(false)
c) error
d) none of the mentioned
View Answer
6. What will be the output of the following PHP code?
1.<?php
2.interface MyInterface
3.{
4.}
5.
6.class MyClass implements MyInterface
7.{
8.}
9.
10. $a = new MyClass;
11.
12. var_dump($a instanceof MyClass);
13. var_dump($a instanceof MyInterface);
14. ?>
a)
bool(false)
bool(false)
b)
bool(true)
bool(true)
c)
bool(false)
bool(true)
d)
bool(true)
bool(false)
View Answer
Answer: b
Explanation: instanceof can also be used to determine whether a variable is an instantiated
object of a class that implements an interface.
7. What should be used to refer to a method in the context of a class rather than an object
you use?
a) ->
b) __
c) $
d) ::
View Answer
Answer: d
Explanation: Example- parent::__construct()
8. Prior to which version of PHP did constructors took the name of the enclosing class.
a) PHP 4
b) PHP 5
c) PHP 5.3
d) PHP 5.4
View Answer
Answer: b
Explanation: The new unified constructors use the name __construct(). Using the old
syntax, a call to a parent constructor would tie you to that particular class:
parent::ShopProduct();
9. Which method or property can only be accessed from within the enclosing class? Even
subclasses have no access.
a) public
b) friendly
c) private
d) protected
View Answer
Answer: c
Explanation: None.
2. Once your application can generate administrative links, you need to load those links into
_________
a) php.ini
b) index.ini
c) index.php
d) start.php
View Ansewr
Answer: c
Explanation: You place your administrative links only on the full display of an entry, so you
must place the call to load information from adminLinks() within a conditional statement
advertisement
3. The URLs in the administrative links won’t mean anything to admin.php unless you
modify _________
a) .htaccess
b) .adminaccess
c) .htmlaccess
d) .urlaccess
View answer
Answer: a
Explanation: You need to modify .htaccess with an additional rule that handles URLs
passed in a link to admin.php.
6. You need to check whether ______ is set, to determine whether you’re editing an entry or
creating a new one.
a) $_GET[‘url’]
b) $_SET[‘url’]
c) $_GET[‘admin’]
d) $_SET[‘admin’]
View Answer
Answer: a
Explanation: If an entry is being edited, you need to load the existing entry data and save
each piece in a variable.
7. To identify entries marked for deletion, you check whether $_GET[‘page’] == ‘delete’
inside __________
a) index.php
b) index.ini
c) admin.php
d) .htaccess
View Answer
8. To declare the function to confirm the deletion you need to add the code to __________
a) inc.php
b) functions.inc.php
c) include.php
d) functions.include.php
View Answer
Answer: b
Explanation: You need to add the following code –
1. function confirmDelete($db, $url)
2. {
3. $e = retrieveEntries($db, '', $url);
4. return <<<FORM
5. <form action="/simple_blog/admin.php" method="post">
6. <fieldset>
7. <legend>Are You Sure?</legend>
8. <p>Are you sure you want to delete the entry "$e[title]"?</p>
9. <input type="submit" name="submit" value="Yes" />
10. <input type="submit" name="submit" value="No" />
11. <input type="hidden" name="action" value="delete" />
12. <input type="hidden" name="url" value="$url" />
13. </fieldset>
14. </form>
15. FORM;
16. }
9. Your confirmation form submits your choice, via the _______ method, to ________
a) GET index.php
b) GET admin.php
c) POST index.php
d) POST admin.php
View Answer
Answer: d
Explanation: To process this, you need to add an additional block of code to the top of
admin.php that determines what choices you’ve made and act accordingly.
10. When a user confirms that he wishes to delete an entry, that entry’s URL is passed to a
function which removes the entry from the __________
a) index.php
b) function.inc.php
c) database
d) admin.php
View Answer
Answer: c
1. Before you can start processing images with PHP, you must first add the ability to upload
images to your administrative form on ________
a) .htaccess
b) function.inc.php
c) index.php
d) admin.php
View Answer
Answer: d
Explanation: To do this, you’ need to add a file upload input to your administrative form.
2. When you’re uploading files you need to set the enctype of the form to __________
a) text
b) text/file
c) multipart/form-data
d) multimedia/form-data
View Answer
Answer: c
Explanation: Set the enctype of the form to multipart/form-data, which can accept files and
standard form values.
3. To check whether a file was uploaded, you look in the _______ superglobal array.
a) $_FILES
b) $_DOCS
c) $_DOCUMENTS
d) $_FOLDERS
View Answer
Answer: a
Explanation: Whenever a file is uploaded via an HTML form, that file is stored in temporary
memory and information about the file is passed in the $_FILES superglobal.
advertisement
4. To make the ImageHandler class portable you should create a separate file for it called
__________
a) imagehandler.inc.php
b) images.inc.php
c) handler.inc.php
d) imghandler.inc.php
View Answer
Answer: b
Explanation: You save this file in the inc folder (full path:
/xampp/htdocs/simple_blog/inc/images.inc.php).
6. To process the file, you need to break the array from $_FILES into individual values. You
can do this using the ________ function.
a) divide()
b) list()
c) break()
d) indi()
View Answer
Answer: b
Explanation: The list() function allows you to create named variables for each array index as
a comma-separated list.
7. Before you try to process the file, you need to make sure that your $err value is
equivalent to _________
a) UPLOAD_ERR_OK
b) UPLOAD_NO_ERR
c) UPLOAD_ERR_NO_OK
d) UPLOAD_ERR
View Answer
Answer: a
Explanation: When you’re dealing with files uploaded through an HTML form, you have
access to a special constant called UPLOAD_ERR_OK that tells you whether a file
uploaded successfully.
8. You use the $_SERVER superglobal and your _______ property to create your path to
check.
a) $load_dir
b) $load
c) $save
d) $save_dir
View Answer
Answer: d
Explanation: // Determines the path to check
$path = $_SERVER['DOCUMENT_ROOT'] . $this->save_dir;
9. Which function do you have to use to check whether the $path you’ve stored exists?
a) path_dir()
b) path()
c) is_dir()
d) path_dir()
View Answer
Answer: c
Explanation: If the path exists, is_dir() returns TRUE; otherwise, it returns FALSE.
10. Which one of the following is true about the following line – $obj = new
ImageHandler(‘/images/’, array(400, 300));?
a) This snippet sets the maximum dimensions allowed to 400 pixels wide by 300 pixels high
b) This snippet sets the minimum dimensions allowed to 300 pixels wide by 400 pixels high
c) This snippet sets the minimum dimensions allowed to 400 pixels wide by 300 pixels high
d) This snippet sets the maximum dimensions allowed to 300 pixels wide by 400 pixels high
View Answer
Answer: a
2. Which keyword is used to access a static method or property from within the same
class(rather than from child)?
a) static
b) strat
c) self
d) set
View Answer
Answer: c
Explanation: Self is to classes what the $this pseudo-variable is to objects.
3. In which of the following circumstance should you use a static reference to a non static
method?
a) Making a method call using parent
b) Making a method call using child
c) Making an object call using parent
d) Making an object call using child
View Answer
Answer: a
Explanation: Making a method call using parent is the only circumstance in which you
should use a static reference to a non-static method.
advertisement
4. Which one of the following variable cannot be used inside a static method?
a) $this
b) $get
c) $set
d) $date
View Answer
Answer: a
Explanation: By definition, static methods are not invoked in the context of an object. For
this reason, static methods and properties are often referred to as class variables and
properties.
6. Which version of PHP allows you to define constant properties within a class?
a) PHP 4
b) PHP 4.1
c) PHP 4.3
d) PHP 5
View Answer
Answer: d
Explanation: None.
9. What will happen if you try to set a value to a constant once it has been declared?
a) The value of the variable will change
b) The value of the variable will not change
c) Parse Error
d) Nothing
View Answer
Answer: c
Explanation: You should use constants when your property needs to be available across all
instances of a class, and when the property value needs to be fixed and unchanging.
i) boolean
ii) integer
iii) float
iv) string
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: d
2. Which one of the following keywords are used to define an abstract class?
a) extends
b) implements
c) abstract
d) new
View Answer
Answer: c
Explanation: The introduction of abstract classes was one of the major changes ushered in
with PHP 5. Its inclusion in the list of new features was another sign of PHP’s extended
commitment to object-oriented design.
6. Which version of PHP introduced the concept called late static binding?
a) PHP 4
b) PHP 5
c) PHP 5.1
d) PHP 5.3
View Answer
Answer: d
Explanation: None.
7. Which one of the following methods in the exception class, is used to get a nested
exception object?
a) getPrevious()
b) getCode()
c) getFile()
d) getLine()
View Answer
Answer: a
Explanation: getCode() – Get the code integer that was passed to the constructor. getFile()
– Get the file in which the exception was generated. getLine() – Get the line number at
which the exception was generated.
8. Which one of the following keyword is used in conjunction with an Exception object?
a) throws
b) exception
c) throw
d) final
View Answer
Answer: c
Explanation: The throw keyword is used in conjunction with an Exception object. It halts the
execution of the current method and passes responsibility for handling the error back to the
calling code.
10. PHP provides built-in interceptor methods, which can intercept messages sent to
undefined methods and properties. This is also known as _________
a) overloading
b) overriding
c) overbending
d) overbinding
View Answer
Answer: a
1. Which one of the following method is invoked when a value is assigned to an undefined
property?
a) __get()
b) __set()
c) __isset()
d) __call()
View Answer
Answer: b
Explanation: The __set() method is invoked when client code attempts to assign to an
undefined property. It is passed two arguments: the name of the property, and the value the
client is attempting to set.
2. Which one of the following method is invoked when an undefined method is called by
client code?
a) __get()
b) __isset()
c) __unset()
d) __call()
View Answer
Answer: d
Explanation: The __call() method is probably the most useful of all the interceptor methods.
The __call() method can be useful for delegation. Delegation is the mechanism by which
one object passes method invocations on to a second.
1.class CopyMe {}
2.$first = new CopyMe();
3.$second = $first;
6. What will be the output of the following PHP code? (Before the version PHP 5.2)
1.class StringThing {}
2.$st = new StringThing();
3.print $st;
1.class Person
2.{
3. function getName() { return "Bob"; }
4. function getAge() { return 44; }
5. function __toString() {
6. $desc = $this->getName();
7. $desc .= " (age ".$this->getAge().")";
8. return $desc;
9. }
10. }
11. $person = new Person();
12. print $person;
1.class Checkout
2. {
3. final function totalize()
4. {
5. // calculate bill
6. }
7. }
8.
9.class IllegalCheckout extends Checkout
10. {
11. final function totalize()
12. {
13. // change bill calculation
14. }
15. }
a) PHP Fatal error: Class IllegalCheckout may not inherit from final class
b) Value of the bill calculated
c) PHP Fatal error: Cannot find object
d) PHP Fatal error: Cannot override final method
View Answer
Answer: d
2. Till which version of PHP, developers were forced to name their files in a global context?
a) PHP 4
b) PHP 5
c) PHP 5.2
d) PHP 5.3
View Answer
Answer: d
Explanation: If you named a class ShoppingBasket, it would become instantly available
across your system.
i) classes
ii) functions
iii) variables
advertisement
a) i)
b) ii)
c) iii)
d) i), ii) & iii)
View Answer
Answer: d
Explanation: A namespace is a bucket in which you can place your classes, functions and
variables.
6. Output:
namespace main;
com\getinstance\util\Debug::helloWorld()
PHP Fatal error: Class 'main\com\getinstance\util\Debug' not found in ...
Using which one of the following PHP lines will the error be removed?
a) \\com\getinstance\util\Debug::helloWorld();
b) getinstance\util\Debug::helloWorld();
c) main.com\getinstance\util\Debug::helloWorld();
d) \com\getinstance\util\Debug::helloWorld();
View Answer
Answer: d
Explanation: PHP is looking below the namespace main for com\getinstance\util and not
finding it. That’s because we are using a relative namespace here. Just as you can make
absolute URLs and filepaths by starting off with a separator so you can with namespaces.
namespace main;
com\getinstance\util\Debug::helloWorld()
PHP Fatal error: Class 'main\com\getinstance\util\Debug' not found in ...
a) fix
b) join
c) use
d) namespace
View Answer
Answer: c
Explanation: Use keyword allows you to alias other namespaces within the current
namespace.
Example – namespace main;
use com\getinstance\util;
util\Debug::helloWorld();
8. If I already had a Debug class in the main namespace. What will be the output of the
following PHP code?
1.namespace main;
2.use com\getinstance\util\Debug;
3.
4.class Debug {
5. static function helloWorld() {
6. print "hello from main\Debug";
7. }
8.}
9.
10. Debug::helloWorld();
a) error
b) hello from main
c) hello from main\Debug
d) debug
View Answer
Answer: a
Explanation: PHP Fatal error: Cannot declare class main\Debug because the name is
already in use.
9. Which one of the following statements is true for include_once() and require_once()?
a) Both are exactly the same
b) include_once is used for files where as require_once() is not
c) Both Handle the errors in the same way
d) Both do not handle the errors in the same way
View Answer
Answer: d
Explanation: The only difference between the include() and require() statements lies in their
handling of errors. A file invoked using require() will bring down your entire process when
you meet an error. The same error encountered via a call to include() will merely generate a
warning and end execution of the included file.
10. Which one of the following statements is true for require() and require_once()?
a) They are functions
b) They are statements
c) They’ll not work if the () is not present
d) They can not be used to require files
View Answer
Answer: b
1. Which function was introduced to help automate the inclusion of class files?
a) __load()
b) __preload()
c) __autoload()
d) __inload()
View Answer
Answer: c
Explanation: When the PHP engine encounters an attempt to instantiate an unknown class,
it invokes the __autoload() function, passing it the class name as a string. It is up to the
implementer to define a strategy for locating and including the missing class file.
3. Which one of the following functions will you use to check that the class exists before you
work with it?
a) class_exist()
b) class_exists()
c) exist()
d) exists_class()
View Answer
Answer: b
Explanation: The class_exists() function accepts a string representing the class to check for
and returns a Boolean true value if the class exists and false otherwise.
advertisement
4. Which one of the following will you use to check the class of an object?
a) class()
b) _class()
c) class_check()
d) get_class()
View Answer
Answer: d
Explanation: This function accepts any object as an argument and returns its class name as
a string.
5. PHP 4 did not support instanceof. Instead, which function did it provide?
a) is()
b) get_class()
c) is_a()
d) is_the()
View Answer
Answer: c
Explanation: As of PHP 5.3 is_a() no longer deprecated.
6. You use the get_class_methods() function to return the names of all the methods in the
class. Which function will you use to print it on the screen?
a) printf()
b) print_ar
c) print_r
d) echo
View Answer
Answer: c
Explanation: The function get_class_methods returns an array therefore we cannot use
echo.
7. If you call a method and it doesn’t exist it’ll cause a problem. To check the method which
function will you use?
a) _method()
b) methodexists()
c) is_callable()
d) is_method()
View Answer
Answer: c
Explanation: There is another method which you can use – method_exists() for similar
purpose.
8. What will be the output if a protected method is given as the argument to the function
method_exist()?
a) Method does not exist
b) False
c) Error
d) True
View Answer
Answer: d
Explanation: method_exists() returns true for private and protected methods as well as for
public ones. Remember that the fact that a method exists does not mean that it will be
callable.
9. Which one of the following function should I use to find the parent class of a class?
a) get_parent_class()
b) parent_class()
c) class_parent()
d) get_class_parent()
View Answer
Answer: a
Explanation: The class functions also allow us to chart inheritance relationships.This
function requires either an object or a class name, and it returns the name of the
superclass, if any. If no such class exists, that is, if the class we are testing does not have a
parent, then the function returns false.
10. Which class accepts a class name or an object reference and returns an array of
interface name?
a) class_implements()
b) is_subclass()
c) is_subclass_of()
d) class_interface()
View Answer
Answer: a
2. Placing a static method for generating ________ objects in the ____________ class is
convenient.
a) child parent
b) parent child
c) final static
d) static final
View Answer
Answer: a
Explanation: Such a design decision does have its own consequences, however.
3. The extent to which proximate procedures are related to one another is known as
________
a) Coupling
b) Balancing
c) Cohesion
d) Co-relation
View Answer
Answer: c
Explanation: Ideally, you should create components that share a clear responsibility. If your
code spreads related routines widely, you will find them harder to maintain as you have to
hunt around to make changes. Our Param Handler classes collect related procedures into a
common context.
advertisement
4. ______ occurs when discrete parts of a system’s code are tightly bound up with one
another so that a change in one part necessitates changes in the others.
a) Loose Coupling
b) Tight Coupling
c) Co-relation
d) Balancing
View Answer
Answer: b
Explanation: Tight coupling is by no means unique to procedural code, though the
sequential nature of such code makes it prone to the problem.
5. ________ code makes change easier because the impact of altering an implementation
will be localized to the component being altered.
a) Orthogonal
b) Cohesion
c) Coupling
d) Balancing
View Answer
Answer: a
Explanation: Orthogonality, it is argued, promotes reuse in that components can be plugged
into new systems without needing any special configuration. Such components will have
clear inputs and outputs independent of any wider context.
10. In a class diagram the class is divided into three sections, what is displayed in the first
section?
a) Class Attributes
b) Class Declaration
c) Class Name
d) Class Functions
View Answer
Answer: c
1. ________ are used in class diagrams to describe the way in which specific elements
should be used.
a) Attributes
b) Constraints
c) Constants
d) Class Names
View Answer
Answer: b
Explanation: The {abstract} syntax is an example of a constraint. There is no special
structure for the text between the braces; it should simply provide a short clarification of any
conditions that may apply to the element.
2. Which one of the following is displayed below the class name in the class diagrams?
a) Functions
b) Methods
c) Attributes
d) Constraints
view Answer
Answer: c
Explanation: Attributes describe a class’s properties. Attributes are listed in the section
directly beneath the class name.
9. Which one of the following is displayed in the third section of the class diagram?
a) Operations
b) Inheritance
c) Abstraction
d) Coupling
View Answer
Answer: a
Explanation: Operations describe methods, or more properly, they describe the calls that
can be made on an instance of a class.
1.<?php
2."Hello World"
3.?>
a) Error
b) Hello World
c) Nothing
d) Missing semicolon error
View Answer
Answer: c
Explanation: If you need to output something onto the screen you’ll need to use echo or
print_r.
advertisement
1.<?php
2.print_r "Hello world"
3.?>
a) Error
b) Hello World
c) Nothing
d) Missing semicolon error
View Answer
Answer: a
Explanation: The statement should be print_r(‘Hello World’) to print Hello world. Also if there
is only one line then there is no requirement of a semicolon, but it is better to use it.
1.<?php
2.echo 'Hello World';
3.<html>
4.Hello world
5.</html>
6.?>
a) Hello world
b) Hello World Hello World
c)
Hello world
Hello World
d) Syntax Error
View Answer
Answer: d
Explanation: Parse error: syntax error, unexpected ‘<‘ on line 2. You can not use the html
tag inside php tags.
1.<?php
2.Echo "Hello World1";
3.echo " Hello world2";
4.ECHO " Hello world3";
5.?>
Hello world1
Hello world2
Hello World3
c) Error
d) Hello world1 Hello world3
View Answer
Answer: a
Explanation: In PHP, all user-defined functions, classes, and keywords (e.g. if, else, while,
echo, etc.) are case-insensitive.
1.<?php
2.$color = "red";
3.echo "$color";
4.echo "$COLOR";
5.echo "$Color";
6.?>
a) redredred
b) redred
c) red
d) Error
View Answer
Answer: c
Explanation: In PHP, all variables are case-sensitive.
1.<?php
2. # echo "Hello world";
3. echo "# Hello world";
4.?>
a) # Hello world
b) Hello world# Hello world
c) Hello world
d) Error
View Answer
Answer: a
Explanation: # is a single line comment.
1.<?php
2.echo "<i>Hello World</i>"
3.?>
a) Hello world
b) Hello world in italics
c) Nothing
d) Error
View Answer
Answer: b
Explanation: You can use tags like italics, bold etc. inside php script.
1.<?php
2.echo "echo "Hello World"";
3.?>
a) Hello world
b) echo “Hello world”
c) echo Hello world
d) Error
View Answer
Answer: d
Explanation: It would have printed echo “Hello world” if we have put backslash
doublequotes just before and just after Hello World string.
1.<?php
2.<?php
3.echo "Hello world";
4.?>
5.?>
a) HELLO WORLD
b) Hello world
c) Nothing
d) Error
View Answer
Answer: d
Explanation: You can not have php tags inside a php tag.
1.<?php
2.$color = red;
3.echo "\$color";
4.?>
a) red
b) $color
c) \red
d) Error
View Answer
Answer: b
1.<?php
2./*
3.echo "Hello world";
4.*/
5.?>
a) Hello world
b) Nothing
c) Error
d)
/*
Hello world
*/
View Answer
Answer: b
Explanation: /* */ is used for commenting multiple lines.
advertisement
1.<?php
2.$color = red;
3.echo "$color" . red ;
4.?>
a) red red
b) red
c) error
d) nothing
View Answer
Answer: c
Explanation: Use of undefined constant red.
1.<?php
2.$color1 = red;
3.$color2 = green;
4.echo "$color1"."$color2";
5.?>
a) red green
b) red
c) green
d) error
View Answer
Answer: d
Explanation: It has to be $color1 = “red”; and $color2 = “green”; therefore the error.
1.<?php
2.$color = "red";
3.$color = "green";
4.echo "$color";
5.?>
a) red
b) green
c) red green
d) error
View Answer
Answer: b
Explanation: The variable contains the last value which has been assigned.
a) red
b) green
c) red green
d) redgreen
View Answer
Answer: d
Explanation: The . operator is used to join to strings.
1.<?php
2.$color1 = "red";
3.$color2 = "green";
4.echo "$color1" + "$color2";
5.?>
a) redgreen
b) red green
c) 0
d) error
View Answer
Answer: c
Explanation: + operator does not join both the strings.
1.<?php
2.$color1 = "red";
3.$color2 = "red";
4.echo "$color1" + "$color2";
5.?>
a) redgreen
b) red green
c) 0
d) 1
View Answer
Answer: c
Explanation: + does not return 1 if the variables are equal.
1.<?php
2.$color1 = "red";
3.$color2 = "1";
4.echo "$color1" + "$color2";
5.?>
a) red1
b) red 1
c) 0
d) 1
View Answer
Answer: d
Explanation: + just returns the numeric value even though it is inside double quotes.
1.<?php
2.$color1 = "1";
3.$color2 = "1";
4.echo "$color1" + "$color2";
5.?>
a) 11
b) 2
c) 0
d) 1
View Answer
Answer: b
Explanation: + can be used to add to integer values which are enclosed by double-quotes.
1.<?php
2.$color1 = "red";
3.$color2 = "1";
4.$color3 = "grey"
5.echo "$color1" + "$color2" . "$color3";
6.?>
a) 1grey
b) grey
c) 0
d) red1grey
View Answer
Answer: a
1.<?php
2.$x = 5;
3.$y = 10;
4.$z = "$x + $y";
5.echo "$z";
6.?>
a) 15
b) 10 + 5
c) $z
d) $x + $y
View Answer
Answer: b
Explanation: Variable z will store 10 + 5 because 10 + 5 is given in double-quotes.
advertisement
1.<?php
2.$x = 4;
3.$y = 3;
4.$z = 1;
5.echo "$x = $x + $y + $z";
6.?>
a) 4 = 4 + 3 + 1
b) 8
c) 8 = 4 + 3 +1
d) Error
View Answer
Answer: a
Explanation: Again since the variables are inside double quotes we get this result.
1.<?php
2.$x = 4;
3.$y = 3
4.$z = 1;
5.$z = $z + $x + $y;
6.echo "$z";
7.?>
a) $z
b) 15
c) 8
d) 1
View Answer
Answer: c
Explanation: Normal addition of variables x, y and z occurs and result of 8 will be displayed.
1.<?php
2.$x = 3.3;
3.$y = 2;
4.echo $x % $y;
5.?>
a) 0
b) 1
c) 2
d) Error
View Answer
Answer: b
Explanation: % is the modulo operator. Unlike in C we can use it get reminder or floating
point numbers in PHP.
1.<?php
2.$x = 10;
3.$y = 4;
4.$z = 3;
5.echo $x % $y % $z;
6.?>
a) 0
b) 1
c) 2
d) Error
View Answer
Answer: c
Explanation: The expression is considered as ($x%$y)%z in this case (10%4)%3 which is 2.
1.<?php
2.$x = 10;
3.$y = 4;
4.$z = 3;
5.echo ($x % ($y) + $z);
6.?>
a) 5
b) 3
c) 0
d) 1
View Answer
Answer: a
Explanation: The innermost bracket is evaluated first, since it covers only variable y it is as
good as not using brackets.
1.<?php
2.$x = 30;
3.$y = 20;
4.$z = 10;
5.echo $x + $y - $z / ($z - $y);
6.?>
a) 41
b) -4
c) -5
d) 51
View Answer
Answer: d
Explanation: First ($z – $y) is evaluated then -$z/($z – $y) is evaluated this results in 1
which is added to $x + $y therefore we get 51.
1.<?php
2.$x = -1;
3.$y = 1;
4.$z = $x * $y + $z;
5.echo $z;
6.?>
a) Undefined variable z
b) -1
c)
Undefined variable z
-1
1.<?php
2.$x = 4;
3.$y = -3;
4.$z = 11;
5.echo 4 + $y * $z / $x;
6.?>
a) 4.25
b) 3.25
c) -3.25
d) -4.25
View Answer
Answer: d
Explanation: First the * is evaluated then / followed by + therefore we can rewrite this
expression as 4 +((- 3 * 11) / 4) which results in -4.25.
10. What will be the output of the following PHP code?
1.<?php
2.$x = 3.5;
3.$y = 2;
4.$z = 2;
5.echo $x / $y / $z;
6.?>
a) 1.75
b) 0.875
c) 3.5
d) Error
View Answer
Answer: b
1.<?php
2.one = 1;
3.two = 2;
4.three = 3;
5.four = 4;
6.echo "one / two + three / four";
7.?>
a) 0.75
b) 0.05
c) 1.25
d) Error
View Answer
Answer: d
Explanation: Variables should start with a $ symbol, since one, two, three, four don’t begin
with $ symbol we’ll get an error.
advertisement
1.<?php
2.$on$e = 1;
3.$tw$o = 2;
4.$thre$e = 3;
5.$fou$r = 4;
6.echo "$on$e / $tw$o + $thre$e / $fou$r";
7.?>
a) 0.75
b) 0.05
c) 1.25
d) Error
View Answer
Answer: d
Explanation: You can not use the $ in between the variable name.
1.<?php
2.$on_e = 1;
3.$tw_o = 2;
4.$thre_e = 3;
5.$fou_r = 4;
6.echo $on_e / $tw_o + $thre_e / $fou_r;
7.?>
a) 0.75
b) 0.05
c) 1.25
d) Error
View Answer
Answer: c
Explanation: You can use _ in a variable name.
1.<?php
2.$On_e = 1;
3.$tw_o = 2;
4.$thre_e = 3;
5.$fou_r = 4;
6.echo $on_e / $tw_o + $thre_e / $fou_r;
7.?>
a) 0.75
b) 0.05
c) 1.25
d) Error
View Answer
Answer: a
Explanation: Since the variable initialised is $On_e and the variable in the echo statement is
$on_e the echo statement treats $on_e as 0;
1.<?php
2.echo $red;
3.?>
a) 0
b) Nothing
c) True
d) Error
View Answer
Answer: b
Explanation: There will no output returned as the variable $red does not hold any value.
1.<?php
2.$four4 = 4;
3.$three3 = 3;
4.$two2 = 2;
5.echo $four4 + $three3 / $two2 - 1;
6.?>
a) 4.5
b) 7
c) 3.5
d) Error
View Answer
Answer: a
Explanation: You can use numbers in a variable name.
1.<?php
2.$4four = 4;
3.$3three = 3;
4.$2two = 2;
5.echo $4four + $3three / $2two - 1;
6.?>
a) 4.5
b) 7
c) 3.5
d) Error
View Answer
Answer: d
Explanation: A variable name can not start with a numeric value.
1.<?php
2.int $one = 1;
3.echo "$one";
4.?>
a) 0
b) 1
c) $one
d) Error
View Answer
Answer: d
Explanation: Unlike other programming languages there are no data types in PHP.
9. What will be the output of the following PHP code?
1.<?php
2.var $one = 1;
3.var $two = 2;
4.echo $one / $two * $one / $two * $two;
5.?>
a) 1
b) 0
c) 0.5
d) Error
View Answer
Answer: d
Explanation: You can not use var before a variable name.
1.<?php
2.$hello = "Hello World";
3.$bye = "Bye";
4.echo $hello;"$bye";
5.?>
a) Hello World
b) Bye
c) Hello worldBye
d) Error
View Answer
Answer: a
1.<?php
2.$x;
3.echo "$x";
4.?>
a) 0
b) 1
c) Nothing
d) Error
View Answer
Answer: c
Explanation: Since the variable x is not initialised it is not storing any value, therefore
nothing will be printed on the screen.
advertisement
2. What will be the output of the following PHP code?
1.<?php
2.$x = 5;
3.{
4. $x = 10;
5. echo "$x";
6.}
7.echo "$x";
8.?>
a) 1010
b) 105
c) 510
d) error
View Answer
Answer: a
Explanation: Variable x stores the value 10 and not 5.
1.<?php
2.$x = 5;
3.{
4. echo "$x";
5.}
6.?>
a) 0
b) 5
c) Nothing
d) Error
View Answer
Answer: b
Explanation: The variable x stores the value 5 and therefore the value 5 is printed on the
screen.
1.<?php
2.$x = 5;
3.function fun()
4.{
5. echo "$x";
6.}
7.fun();
8.?>
a) 0
b) 5
c) Nothing
d) Error
View Answer
Answer: c
Explanation: The variable x is not defined inside the function fun(), therefore nothing is
printed on the screen.
1.<?php
2.$x = 5;
3.function fun()
4.{
5. $x = 10;
6. echo "$x";
7.}
8.fun();
9.echo "$x";
10. ?>
a) 0
b) 105
c) 510
d) Error
View Answer
Answer: b
Explanation: First when the function is called variable x is initialised to 10 so 10 is printed
later the global value 5 is printed.
1.<?php
2.$x = 4;
3.$y = 3;
4.function fun($x = 3, $y = 4)
5.{
6. $z = $x+$y/$y+$x;
7. echo "$z";
8.}
9.echo $x;
10. echo $y;
11. echo $z;
12. fun($x, $y);
13. ?>
a) 43
b) 943
c) 349
d) 439
View Answer
Answer: d
Explanation: Firstly, the statements outside the function are printed, since z is not defined
it’ll no value is printed for z. Next the function is called and the value of z inside the function
is printed.
1.<?php
2.$x = 4;
3.$y = 3;
4.function fun($x, $y)
5.{
6. $z = $x + $y / $y + $x;
7. echo "$z";
8.}
9.echo $x;
10. echo $y;
11. echo $z;
12. fun(3, 4);
13. ?>
a) 437
b) 439
c) 349
d) 347
View Answer
Answer: a
Explanation: It is same as above but the value passed into the function is 3,4 and not 4,3.
Therefore the difference in answer.
1.<?php
2.function fun($x,$y)
3.{
4. $x = 4;
5. $y = 3;
6. $z = $x + $y / $y + $x;
7. echo "$z";
8.}
9.fun(3, 4);
10. ?>
a) 7
b) 9
c) 0
d) Error
View Answer
Answer: b
Explanation: Value 3, 4 is passed to the function but that is lost because x and y are
initialised to 4 and 3 inside the function. Therefore we get the given result.
a) 3
b) 4
c) 6
d) Error
View Answer
Answer: d
Explanation: In C you won’t get an error but in PHP you’ll get a syntax error.
1.<?php
2.$a = 10;
3.$b = 4;
4.$c = fun(10,4);
5.function fun($a,$b)
6.{
7. $b = 3;
8. return $a - $b + $b - $a;
9.}
10. echo $a;
11. echo $b;
12. echo $c;
13. ?>
a) 104
b) 410
c) 1400
d) 4100
View Answer
Answer: c
1.<?php
2.print "echo hello world";
3.?>
a) 01
b) 11
c) 10
d) Error
View Answer
Answer: b
Explanation: Print can be used with or without parentheses.
1.<?php
2.$cars = array("Volvo", "BMW", "Toyota");
3.print $cars[2];
4.?>
a) Volvo
b) BMW
c) Toyota
d) Error
View Answer
Answer: c
Explanation: Print statement can be used to output a specific array member.
1.<?php
2.$one = "one";
3.$two = "two";
4.print($one$two);
5.?>
a) onetwo
b) one
c) nothing
d) error
View Answer
Answer: d
Explanation: The above syntax will produce an error, unlike the echo statement.
1.<?php
2.$one = "one";
3.$two = "two";
4.print($one,$two);
5.?>
a) onetwo
b) one, two
c) one
d) error
View Answer
Answer: d
Explanation: The above syntax will produce an error, unlike the echo statement.
1.<?php
2.$one = "one";
3.$two = "two";
4.print("$one$two");
5.?>
a) onetwo
b) $one$two
c) one
d) error
View Answer
Answer: a
Explanation: This is same as the echo statement.
1.<?php
2.$one = "one";
3.$two = "two";
4.print($one==$two);
5.?>
a) true
b) false
c) nothing
d) error
View Answer
Answer: c
Explanation: Since we are equating two unequal strings we do not get any output.
1.<?php
2.$one = "one";
3.$two = "one";
4.print($one == $two);
5.?>
a) true
b) false
c) 1
d) error
View Answer
Answer: c
Explanation: Since both the strings are equal the result 1 is printed on the screen.
1.<?php
2.print "Hello world!<br>";
3.print "I'm about to learn PHP!";
4.?>
a) Hello world!
I’m about to learn PHP!
b) Hello world! I’m about to learn PHP!
c)
Hello world!
d) Error
View Answer
Answer: c
Explanation: Most of the properties of echo and print are same. Strings can contain HTML
markup.
1.<?php
2.print("this"."was"."a"."bad"."idea");
3.?>
a) thiswasabadidea
b) this was a bad idea
c) nothing
d) error
View Answer
Answer: a
1.<?php
2.echo 5 * 9 / 3 + 9;
3.?>
a) 24
b) 3.7
c) 3.85
d) 0
View Answer
Answer: a
Explanation: Operator precedence order must be followed.
advertisement
1.<?php
2.echo 5 * 9 / 3 + 9
3.?>
a) 24
b) 3.7
c) 3.85
d) 0
View Answer
Answer: a
Explanation: Operator precedence order must be followed.
1.<?php
2.$i = 0;
3.$j = 0;
4.if ($i && ($j = $i + 10)) {
5. echo "true";
6.}
7.echo $j;
8.?>
a) 10
b) 0
c) true0
d) true10
View Answer
Answer: b
Explanation: In if condition when the first case is 0 and is an && operation then the second
command is not executed.
1.<?php
2.$i = 10;
3.$j = 0;
4.if ($i || ($j = $i + 10)) {
5. echo "true";
6.}
7.echo $j;
8.?>
a) 20
b) true0
c) 0
d) true20
View Answer
Answer: b
Explanation: In if condition when the first case is 1 and is an || operation then the second
command is not executed.
1.<?php
2.$i = 1;
3.if ($i++ && ($i == 1))
4. printf("Yes\n$i");
5.else
6. printf("No\n$i");
7.?>
a) No 2
b) Yes 1
c) Yes 2
d) No 1
View Answer
Answer: a
Explanation: The first condition returns true and increments but the second condition is
false.
1.<?php
2.$a = 1; $b = 3;
3.$d = $a++ + ++$b;
4.echo $d;
5.?>
a) 5
b) 4
c) 3
d) error
View Answer
Answer: a
Explanation: Post increment of a is done after expression evaluation.
1.<?php
2.$a = 1; $b = 1; $d = 1;
3.print ++$a + ++$a+$a++; print $a++ + ++$b; print ++$d + $d++ + $a++;
4.?>
a) 869
b) 742
c) 368
d) error
View Answer
Answer: a
Explanation: Follow the order of post and pre increments.
1.<?php
2.$a = 10; $b = 10;
3.if ($a = 5)
4. $b--;
5.print $a;print $b--;
6.?>
a) 58
b) 59
c) 109
d) 108
View Answer
Answer: b
Explanation: a is set to 5 in the if condition and b is post decremented in the print statement.
1.<?php
2.$i = 0;
3.$x = $i++; $y = ++$i;
4.print $x; print $y;
5.?>
a) 02
b) 12
c) 01
d) 21
View Answer
Answer: a
Explanation: First case i is incremented after setting x to i.
1.<?php
2. $a = 5; $b = -7; $c =0;
3. $d = ++$a && ++$b || ++$c;
4. print $d; print $a;
5.?>
a) 16
b) 06
c) 15
d) 05
View Answer
Answer: a
Explanation: 1&&0||1 is evaluated to 1 and the a is also preincremented to 6.
1.<?php
2.$b = 1; $c = 4; $a = 5;
3.$d = $b + $c == $a;
4.print $d;
5.?>
a) 5
b) 0
c) 10
d) 1
View Answer
Answer: d
1.<?php
2.echo 5 * 9 / 3 + 9;
3.?>
a) 24
b) 3.7
c) 3.85
d) 0
View Answer
Answer: a
Explanation: Operator precedence order must be followed.
advertisement
1.<?php
2.$var1 = 1 + ++5;
3.echo $var1;
4.?>
a) no output
b) error
c) 6
d) 7
View Answer
Answer: b
Explanation: Operator ++ can be done only on variables.
a) 5
b) error
c) 6
d) 7
View Answer
Answer: b
Explanation: Operator ++ can be done only on variables.
1.<?php
2.$var1 = 0;
3.$var1 = $var1++ + 5;
4.echo $var1;
5.?>
a) 5
b) error
c) 6
d) 7
View Answer
Answer: a
Explanation: Operator precedence followed.
1.<?php
2.$var1 = 0;
3.$var1 = ++$var1 + 5;
4.echo $var1;
5.?>
a) 5
b) error
c) 6
d) 7
View Answer
Answer: c
Explanation: Operator precedence followed.
1.<?php
2.$var1 = 0;
3.$var1 = $var1 + 5;
4.echo $var1++;
5.?>
a) 5
b) error
c) 6
d) 7
View Answer
Answer: a
Explanation: Operator precedence followed,incremented after display.
1.<?php
2.$var1 = 1;
3.echo $var1 = ++$var1 % 2 + ++$var1;
4.?>
a) 1
b) 0
c) 2
d) 3
View Answer
Answer: d
Explanation: Evaluation done from right to left.
1.<?php
2. $a = 5;$b = -7;$c =0;
3. $d = ++$a && ++$b || ++$c;
4. print $d;print $a;
5.?>
a) 16
b) 06
c) 15
d) 05
View Answer
Answer: a
Explanation: 1&&0||1 is evaluated to 1 and the a is also pre incremented to 6.
1.<?php
2.$var1 = 3;
3.print $var = ++$var;
4.?>
a) 1
b) 0
c) 2
d) 3
View Answer
Answer: a
Explanation: $var = ++$var returns 1(success).
1.<?php
2.$var1 = 3;
3.print ++$var++;
4.?>
a) 3
b) 4
c) 5
d) error
View Answer
Answer: d
1.<?php
2.$i = 0; $j = 1; $k = 2;
3.print !(($i + $k) < ($j - $k));
4.?>
a) 1
b) true
c) false
d) 0
View Answer
Answer: a
Explanation: True is 1.
advertisement
1.<?php
2.$i = 0;$j = 1;$k = 2;
3.print !(( + + $i + $j) > ($j - $k));
4.?>
a) 1
b) no output
c) error
d) 0
View Answer
Answer: b
Explanation: The equation outputs false .
a) 1
b) no output
c) error
d) 0
View Answer
Answer: a
Explanation: Negation of a number is 0.
1.<?php
2.$a = 0x6db7;
3.print $a<<6;
4.?>
a) 1797568
b) no output
c) error
d) 0x6dc0
View Answer
Answer: a
Explanation: The output is in decimal.
1.<?php
2.$a = 'a' ;
3.print $a * 2;
4.?>
a) 192
b) 2
c) error
d) 0
View Answer
Answer: d
Explanation: Characters cannot be multiplied.
1.<?php
2.$a = '4' ;
3.print + + $a;
4.?>
a) no output
b) error
c) 5
d) 0
View Answer
Answer: c
Explanation: The character is type casted to integer before multiplying.
1.<?php
2.$a = '12345';
3.print "qwe{$a}rty";
4.?>
a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output
View Answer
Answer: a
Explanation: {$}dereferences the variable within.
1.<?php
2.$a = '12345';
3.print "qwe".$a."rty";
4.?>
a) qwe12345rty
b) qwe$arty
c) error
d) no output
View Answer
Answer: a
Explanation: . dereferences the variable/string within.
1.<?php
2.$a = '12345';
3.echo 'qwe{$a}rty';
4.?>
a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output
View Answer
Answer: b
Explanation: qwe{$a}rty, single quotes are not parsed.
10. What will be the output of the following PHP code?
1.<?php
2.$a = '12345';
3.echo "qwe$arty";
4.?>
a) qwe12345rty
b) qwe$arty
c) qwe
d) error
View Answer
Answer: c
1.<?php
2.$x;
3.if ($x)
4. print "hi" ;
5.else
6. print "how are u";
7.?>
a) how are u
b) hi
c) error
d) no output
View Answer
Answer: a
Explanation: Uninitialized x is set to 0, thus if condition fails.
advertisement
1.<?php
2.$x = 0;
3.if ($x++)
4. print "hi";
5.else
6. print "how are u";
7.?>
a) hi
b) no output
c) error
d) how are u
View Answer
Answer: d
Explanation: x is incremented after if which evaluates to false.
3. What will be the output of the following PHP code?
1.<?php
2.$x;
3.if ($x == 0)
4. print "hi" ;
5.else
6. print "how are u";
7. print "hello"
8.?>
1.<?php
2.$x = 0;
3.if ($x == 1)
4. if ($x >= 0)
5. print "true";
6. else
7. print "false";
8.?>
a) true
b) false
c) error
d) no output
View Answer
Answer: d
Explanation: The nested for loop is not entered if outer condition is false.
1.<?php
2.$a = 1;
3.if ($a--)
4. print "True";
5.if ($a++)
6. print "False";
7.?>
a) true
b) false
c) error
d) no output
View Answer
Answer: a
Explanation: Due to post increment and post decrement only the first condition is satisfied.
1.<?php
2.$a = 1;
3.if (echo $a)
4. print "True";
5.else
6. print "False";
7.?>
a) true
b) false
c) error
d) no output
View Answer
Answer: c
Explanation: echo does not return anything so if condition is empty.
1.<?php
2.$a = 1;
3.if (print $a)
4. print "True";
5.else
6. print "False";
7.?>
a) true
b) false
c) error
d) no output
View Answer
Answer: a
Explanation: print returns 1 if it prints anything.
1.<?php
2.$a = 10;
3.if (1)
4. print "all";
5.else
6. print "some"
7.else
8. print "none";
9.?>
a) all
b) some
c) error
d) none
View Answer
Answer: c
Explanation: Hanging else statement.
1.<?php
2.$a = 10;
3.if (0)
4. print "all";
5. if
6. else
7. print "some"
8.?>
a) all
b) some
c) error
d) no output
View Answer
Answer: c
Explanation: No else statement to end the if statement.
1.<?php
2.$a = "";
3.if ($a)
4. print "all";
5.if
6.else
7. print "some";
8.?>
a) all
b) some
c) error
d) no output
View Answer
Answer: b
Explanation: Empty string is evaluated to 0.
1.<?php
2.$a = "a";
3.if ($a)
4. print "all";
5.else
6. print "some";
7.?>
a) all
b) some
c) error
d) no output
View Answer
Answer: a
1.<?php
2.$x = 10;
3.$y = 20;
4.if ($x > $y + $y != 3)
5. print "hi" ;
6.else
7. print "how are u";
8.?>
a) how are u
b) hi
c) error
d) no output
View Answer
Answer: b
Explanation: Expression evaluates to true.
advertisement
1.<?php
2.$x = 10;
3.$y = 20;
4.if ($x > $y && 1||1)
5. print "hi" ;
6.else
7. print "how are u";
8.?>
a) how are u
b) hi
c) error
d) no output
View Answer
Answer: b
Explanation: Expression evaluates to true.
a) how are u
b) hi
c) error
d) no output
View Answer
Answer: b
Explanation: Expression evaluates to true.
1.<?php
2.if (-100)
3. print "hi" ;
4.else
5. print "how are u";
6.?>
a) how are u
b) hi
c) error
d) no output
View Answer
Answer: b
Explanation: Expression evaluates to true.
1.<?php
2.if (0.1)
3. print "hi" ;
4.else
5. print "how are u";
6.?>
a) how are u
b) hi
c) error
d) no output
View Answer
Answer: b
Explanation: Expression evaluates to true.
a) how are u
b) hi
c) error
d) no output
View Answer
Answer: a
Explanation: Expression evaluates to false.
1.<?php
2.if (print "0")
3. print "hi" ;
4.else
5. print "how are u";
6.?>
a) 0how are u
b) 0hi
c) hi
d) how are u
View Answer
Answer: b
Explanation: Expression evaluates to true as print returns 1.
1.<?php
2.$x = 1;
3.if ($x == 2)
4. print "hi" ;
5.else if($x = 2)
6. print $x;
7.else
8. print "how are u";
9.?>
a) error
b) 2
c) hi
d) how are u
View Answer
Answer: b
Explanation: Enters if else as first condition is false and thus x is set to 2.
a) 0
b) 1
c) error
d) how are u
View Answer
Answer: d
Explanation: x&0 is 0,thus evaluated to false.
1.<?php
2.$x = 1;
3.if ($x = $x&0)
4. print $x ;
5.else
6. print "how are u";
7.?>
a) 0
b) 1
c) error
d) how are u
View Answer
Answer: d
Explanation: x&0 is 0,thus evaluated to false.
1.<?php
2.$x = 1;
3.if ($x = $x&0)
4. print $x;
5.else
6. break;
7.?>
a) 0
b) 1
c) error
d) no output
View Answer
Answer: c
Explanation: break is not defined for a if else ladder.
a) M.S.Dhoni
b) M.E.K.Hussey
c)
M.S.Dhoni
M.E.K.Hussey
A.B.de villiers
d) No output
View Answer
Answer: a
1.<?php
2.$x = 10;
3.$y = 5;
4.$z = 3;
5.if ($x / $y / $z)
6. print "hi";
7.else
8. print "hello";
9.?>
a) hi
b) hello
c) error
d) no output
View Answer
Answer: a
Explanation: In php division returns a float that is a non zero value thus evaluates to true.
advertisement
1.<?php
2.if (!print "hi")
3. if (print "hello")
4.print "hi";
5.?>
a) hi
b) hihellohi
c) hihi
d) no output
View Answer
Answer: a
Explanation: Print returns true and thus the first if statement also is not executed.
1.<?php
2.if (print "hi" - 1)
3. print "hello"
4.?>
a) hi
b) hihello
c) error
d) no output
View Answer
Answer: c
Explanation: print returns true and when 1 is subtracted it is syntax error.
1.<?php
2.$x = 1;
3.if ($x--)
4. print "hi"
5. $x--;
6.else
7. print "hello"
8.?>
a) hi
b) hello
c) error
d) no output
View Answer
Answer: c
Explanation: The if statement has no brackets and it expects a else/else if after a if.
1.<?php
2.$a = 10;
3.$b = 11;
4.if ($a < ++$a || $b < ++$b)
5. print "hello";
6.else
7. print "hi";
8.?>
a) hi
b) hello
c) error
d) no output
View Answer
Answer: a
Explanation: The operator precedence of ++ is higher than <, thus the increment happens
first and then compared.
1.<?php
2.$a = 2;
3.if ($a-- - --$a - $a)
4. print "hello";
5.else
6. print "hi";
7.?>
a) hi
b) hello
c) error
d) no output
View Answer
Answer: b
Explanation: Computing the expression in the if clause,it sums upto to 2 which is a positive
value.
1.<?php
2.$a = 2;
3.if ($a-- - --$a - $a)
4. print "hello";
5.else
6. print "hi";
7.?>
a) hi
b) hello
c) error
d) no output
View Answer
Answer: b
Explanation: Computing the expression in the if clause, it sums upto to 2 which is a positive
value.
a) hellolength
b) 5
c) hi
d) error
View Answer
Answer: a
Explanation: The . operator appends a string and returns true.
1.<?php
2.$a = "hello";
3.if (strlen($a))
4. print strlen($a);
5.else
6. print "hi";
7.?>
a) hellolength
b) 5
c) hi
d) error
View Answer
Answer: b
Explanation: The function strlen($a) gives the length of the string, 5, which is considered
true.
1.<?php
2.$a = "1";
3.$b = "0";
4.if ((int)$a && $b)
5. print"hi";
6.else
7. print "hello";
8.?>
a) hello
b) no output
c) hi
d) error
View Answer
Answer: a
1. What will be the output of the following PHP code?
1.<?php
2.$a = "1";
3.switch ($a)
4.{
5.case 1:
6. print "hi";
7.case 2:
8. print "hello";
9.default:
10. print "hi1";
11. }
12. ?>
a) hihellohi1
b) hi
c) hihi1
d) hi1
View Answer
Answer: a
Explanation: As break is not provided it executes all the cases.
advertisement
1.<?php
2.$a = "2";
3.switch ($a)
4.{
5.case 1:
6. print "hi";
7.case 2:
8. print "hello";
9. break;
10. default:
11. print "hi1";
12. }
13. ?>
a) hihellohi1
b) hello
c) hihi1
d) hi1
View Answer
Answer: b
Explanation: As hello is provided after case2 it breaks the loop.
1.<?php
2.$a = "1";
3.switch($a)
4.{
5.case 1:
6. break;
7. print "hi";
8.case 2:
9. print "hello";
10. break;
11. default:
12. print "hi1";
13. }
14. ?>
a) hihellohi1
b) no output
c) hihi1
d) hi1
View Answer
Answer: b
Explanation: As break is provided before print statement in case 2 it breaks the loop before
printing.
1.<?php
2.$a = "1";
3.$a = 1;
4.$b = 1;
5.switch($a)
6.{
7.case $a * $b:
8. print "hi";
9. break;
10. case $a / $b:
11. print "hello";
12. break;
13. default:
14. print "hi1";
15. }
16. ?>
a) hihellohi1
b) hi
c) hihello
d) hi1
View Answer
Answer: b
Explanation: It checks the first case, when it finds it equal it will perform it breaks out.
1.<?php
2.$a = 97;
3.switch($a)
4.{
5.case "a":
6. print "hi";
7. break;
8.case 97:
9. print "hello";
10. break;
11. default:
12. print "hi1";
13. }
14. ?>
a) hihellohi1
b) hi
c) hihello
d) hello
View Answer
Answer: d
Explanation: Downcasting does not happen in case, it compares only with its data type.
1.<?php
2.$b = 1;
3.switch($b)
4.{
5.case 1.0:
6. print "hi";
7. break;
8.case 1:
9. print "hello";
10. break;
11. default:
12. print "hi1";
13. }
14. ?>
a) hihellohi1
b) hi
c) hihello
d) hello
View Answer
Answer: a
Explanation: Upcasting does happen in case, it compares it with 1.0 and thus prints hi and
exits.
1.<?php
2.const $b = 1;
3.switch($b)
4.{
5.case 1:
6. print "hi";
7. break;
8.case 1:
9. print "hello";
10. break;
11. default:
12. print "hi1";
13. }
14. ?>
a) error
b) hi
c) hihello
d) hello
View Answer
Answer: a
Explanation: Constants cannot be used in switch cases.
1.<?php
2.$b = 1;
3.switch(print $b)
4.{
5.case 2:
6. print "hello";
7. break;
8.case 1:
9. print "hi";
10. break;
11. default:
12. print "hi1";
13. }
14. ?>
a) 1hello
b) 1hi
c) 1hi1
d) error
View Answer
Answer: b
Explanation: Print returns 1, thus it gives case 1.
1.<?php
2.switch($b)
3.{
4.case 2:
5. print "hello";
6. break;
7.case 1:
8. print "hi";
9. break;
10. }
11. ?>
a) hello
b) hi
c) no output
d) error
View Answer
Answer: c
Explanation: If that case does not exist then it searches for default and on not finding it does
nothing.
1.<?php
2.switch($b)
3.{
4.case 2:
5. print "hello";
6. break;
7.case b:
8. print "hi";
9. break;
10. }
11. ?>
a) hello
b) hi
c) no output
d) error
View Answer
Answer: c
1.<?php
2.while()
3.{
4. print "hi";
5.}
6.?>
a) infinite loop
b) hi
c) no output
d) error
View Answer
Answer: d
Explanation: The while loop cannot be defined without a condition.
advertisement
2. What will be the output of the following PHP code?
1.<?php
2.do
3.{
4. print "hi";
5.}
6.while(0);
7.print "hello";
8.?>
a) infinite loop
b) hihello
c) hello
d) error
View Answer
Answer: b
Explanation: The do while loop executes at least once as the condition is in the while loop.
1.<?php
2.$i = 0
3.do
4.{
5. print "hi";
6. $i++;
7.}
8.while ($i != 3);
9.?>
a)
hi
hi
b) hi
c)
hi
hi
hi
hi
d) no output
View Answer
Answer: c
Explanation: The check happens after the increment,thus it prints until i = 4.
1.<?php
2.$i = 0
3.while ($i != 3)
4.{
5. print "hi";
6. $i++;
7.}
8.?>
a)
hi
hi
b)
hi
hi
hi
c)
hi
hi
hi
hi
d) no output
View Answer
Answer: b
Explanation: The check happens before the increment, thus it prints until i = 3.
a)
hi
hi
hello
b)
hi
hi
hi
hello
c)
hi
hi
hi
hi
hello
d) infinite loop
View Answer
Answer: d
Explanation: There is no increment of i making it infinite.
6. What will be the output of the following PHP code?
1.<?php
2.$i = 0
3.while ($i < 3)
4.{
5. $i++;
6.}
7.print $i;
8.?>
a) 2
b) 3
c) 0
d) 1
View Answer
Answer: b
Explanation: The increment happens and then the check happens.
1.<?php
2.$i = 0
3.do
4.{
5. $i++;
6.}
7.while ($i < 3);
8.print $i;
9.?>
a) 2
b) 3
c) 0
d) 1
View Answer
Answer: b
Explanation: The increment happens and then the check happens.
1.<?php
2.$i = 0
3.while ($i++)
4.{
5. print $i;
6.}
7.print $i;
8.?>
a) 0
b) infinite loop
c) 01
d) 1
View Answer
Answer: d
Explanation: As it is a post increment, it checks and then does not enter the loop, thus prints
only 1.
1.<?php
2.$i = "";
3.while($i)
4.{
5. print "hi";
6.}
7.print "hello";
8.?>
a) hello
b) infinite loop
c) hihello
d) error
View Answer
Answer: a
Explanation: While accept does not accept anything other than a 0 or any other number as
false and true.
1.<?php
2.$i = "";
3.while ($i)
4.{
5. print "hi";
6.}
7.while($i < 8)
8. $i++;
9.print "hello";
10. ?>
1.<?php
2.$i = 0;
3.while($i = 10)
4.{
5. print "hi";
6.}
7.print "hello";
8.?>
a) hello
b) infinite loop
c) hihello
d) error
View Answer
Answer: b
Explanation: While condition always gives 1.
advertisement
1.<?php
2.$i = "";
3.while ($i = 10)
4.{
5. print "hi";
6.}
7.print "hello";
8.?>
a) hello
b) infinite loop
c) hihello
d) error
View Answer
Answer: b
Explanation: While condition always gives 1.
1.<?php
2.$i = 5;
3.while (--$i > 0)
4.{
5. $i++; print $i; print "hello";
6.}
7.?>
a) 4hello4hello4hello4hello4hello…..infinite
b) 5hello5hello5hello5hello5hello…..infinite
c) no output
d) error
View Answer
Answer: b
Explanation: i is decremented in the while loop in the condition check and then incremented
back.
4. What will be the output of the following PHP code?
1.<?php
2.$i = 5;
3.while (--$i > 0 && ++$i)
4.{
5. print $i;
6.}
7.?>
a) 5
b) 555555555…infinitely
c) 54321
d) error
View Answer
Answer: b
Explanation: As it is && operator it is being incremented and decremented continuously.
1.<?php
2.$i = 5;
3.while (--$i > 0 || ++$i)
4.{
5. print $i;
6.}
7.?>
a) 54321111111….infinitely
b) 555555555…infinitely
c) 54321
d) 5
View Answer
Answer: a
Explanation: As it is || operator the second expression is not evaluated till i becomes 1 then
it goes into a loop.
1.<?php
2.$i = 0;
3.while(++$i || --$i)
4.{
5. print $i;
6.}
7.?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) 1
d) 0
View Answer
Answer: a
Explanation: As it is || operator the second expression is not evaluated and i is always
incremented, in the first case to 1.
1.<?php
2.$i = 0;
3.while (++$i && --$i)
4.{
5. print $i;
6.}
7.?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) no output
d) error
View Answer
Answer: c
Explanation: The first condition itself fails thus the loop exists.
1.<?php
2.$i = 0;
3.while ((--$i > ++$i) - 1)
4.{
5. print $i;
6.}
7.?>
a) 00000000000000000000….infinitely
b) -1-1-1-1-1-1-1-1-1-1…infinitely
c) no output
d) error
View Answer
Answer: a
Explanation: (–$i > ++$i) evaluates to 0 but -1 makes it enters the loop and prints i.
1.<?php
2.$i = 2;
3.while (++$i)
4.{
5. while ($i --> 0)
6. print $i;
7.}
8.?>
a) 210
b) 10
c) no output
d) infinite loop
View Answer
Answer: a
Explanation: The loop ends when i becomes 0.
1.<?php
2.$i = 2;
3.while (++$i)
4.{
5. while (--$i > 0)
6. print $i;
7.}
8.?>
a) 210
b) 10
c) no output
d) infinite loop
View Answer
Answer: d
1.<?php
2.$i = 0;
3.for ($i)
4.{
5. print $i;
6.}
7.?>
a) 0
b) infinite loop
c) no output
d) error
View Answer
Answer: d
Explanation: Wrong syntax for for loop.
advertisement
1.<?php
2.$colors = array("red","green","blue","yellow");
3.foreach ($colors as $value)
4.{
5. echo "$value <br>";
6.}
7.?>
a)
red
green
blue
yellow
b) red
c) no output
d) error
View Answer
Answer: a
Explanation: This runs a for loop for that array.
1.<?php
2.for ($x = 0; $x <= 10; $x++)
3.{
4. echo "The number is: $x <br>";
5.}
6.?>
a)
1.<?php
2.for ($x = 0; $x <= 10; print ++$x)
3.{
4. print ++$x;
5.}
6.?>
a) 123456789101112
b) 12345678910
c) 1234567891011
d) infinite loop
View Answer
Answer: a
Explanation: The value of x is incremented and printed twice before checking,this last loop it
prints 11 and 12.
1.<?php
2.for ($x = 1; $x < 10;++$x)
3.{
4. print "*\t";
5.}
6.?>
a) **********
b) *********
c) ***********
d) infinite loop
View Answer
Answer: b
Explanation: Loop runs from 1 to 9 i.e 9 times.
a) 123456789101112
b) 12345678910
c) 1234567891011
d) infinite loop
View Answer
Answer: d
Explanation: The value of x is decremented thus making it an infinite loop.
1.<?php
2.$x;
3.for ($x = -3; $x < -5; ++$x)
4.{
5. print ++$x;
6.}
7.?>
a) -3-4-5
b) -3-4
c) infinite loop
d) no output
View Answer
Answer: d
Explanation: The loop is not even entered as x is initially 0.
1.<?php
2.for ($i++; $i == 1; $i = 2)
3. print "In for loop ";
4.print "After loop\n";
5.
6.?>
a) In for loop
b) After for loop
c) In for loopAfter for loop
d) Infinite loop
View Answer
Answer: c
Explanation: The loop runs only once as value of x is incremented.
a) In for loop
b) After for loop
c) In for loopAfter for loop
d) Infinite loop
View Answer
Answer: b
Explanation: The loop does not run as i initialized in check statement will be zero.
1.<?php
2.for ($i == 2; ++$i == $i; ++$i)
3. print "In for loop ";
4.print "After loop\n";
5.?>
1.<?php
2.for ($x = 1; $x < 10; $x++)
3. for ($y = 1; $y < 5; $y++)
4. print "Hello";
5.?>
a) Hello….36 times
b) Hello….45 times
c) Hello….50 times
d) Hello….40 times
View Answer
Answer: a
Explanation: 9*4 times is printed.
advertisement
1.<?php
2.for ($count = 1; $count != 20;$count++)
3.{
4. print $count;
5. $count++;
6.}
7.?>
a) Infinite
b) 123…….20
c) 1357…19
d) 13579…21
View Answer
Answer: a
Explanation: Condition always fails as count takes only odd numbers.
1.<?php
2.for ($count = 1; $count < 20; $count++);
3. print $count;
4.?>
a) 20
b) 19
c) 12345678910….19
d) 12345678910….1920
View Answer
Answer: a
Explanation: The for loop has no body, it just runs till condition is satisfied.
1.<?php
2.for ($count = 0; $count < 3;$count++);
3.{
4. print "hi";continue;print "hello";
5.}
6.?>
a) hihihi
b) hihellohihellohihello
c) hellohellohello
d) hi
View Answer
Answer: a
Explanation: When continue is encountered it skips to the next iteration.
1.<?php
2.for ($count = 0; $count<3;$count++);
3.{
4. print "hi";break;print "hello";
5.}
6.?>
a) hihihi
b) hihellohihellohihello
c) hellohellohello
d) hi
View Answer
Answer: d
Explanation: When break is encountered it leaves the loop.
1.<?php
2.for(++$i; ++$i; ++$i)
3.{
4. print $i;
5. if ($i == 4)
6. break;
7.}
8.?>
a) 24
b) 134
c) 1234
d) 1
View Answer
Answer: a
Explanation: The order of execution is initialization, check, increment/decrement, check,
increment/decrement, check, increment/decrement….so on.
1.<?php
2.for ($i = 0;$i = -1;$i = 1)
3.{
4. print $i;
5. if ($i != 1)
6. break;
7.}
8.?>
a) 0
b) infinite loop
c) -1
d) 1
View Answer
Answer: c
Explanation: The order of execution is initialization, check, increment/decrement, check,
increment/decrement, check, increment/decrement….so on.
a) 10
b) infinite loop
c) no output
d) error
View Answer
Answer: b
Explanation: There is no check condition to stop the execution of the loop.
1.<?php
2.for ($i = 0; $i < 3; $i++)
3.{
4. for($j = $i; $j > 0; $j--)
5. print " ";
6. for($k = $j; $k < 3; $k++)
7. print "*";
8. print "\n";
9.}
10. ?>
a)
**
***
b)
***
**
c)
*
**
***
d) error
View Answer
Answer: a
Explanation: Follow the trace of i, j prints 3 – i no of spaces for each i, k prints i stars for
each loop.
1.<?php
2.for ($i = 0; -5 ; $i++)
3.{
4. print"i";
5. if ($i == 3)
6. break;
7.}
8.?>
a) 0 1 2 3 4
b) 0 1 2 3
c) 0 1 2 3 4 5
d) error
View Answer
Answer: b
1.<?php
2. function sum($num1, $num2)
3. {
4. $total = $num1 + $num2;
5. echo "chr($total)";
6. }
7. $var1 = "sum";
8. $var1(5, 44);
9.?>
a) Error
b) 49
c) 1
d) Sum
View Answer
Answer: c
Explanation: It is possible to call a function using a variable which stores the function name
also the chr() function returns a character from the specified ASCII value.
advertisement
1.<?php
2. function sum($num1, $num2)
3. {
4. $total = $num1 + $num2;
5. echo "cos($total)";
6. }
7. sum(5,-5);
8.?>
a) 0
b) 1
c) 0.5
d) -0.5
View Answer
Answer: b
Explanation: cos() gives the cos value of the argument. Here the function returns 1.
1.<?php
2. function b()
3. {
4. echo "b is executed";
5. }
6. function a()
7. {
8. b();
9. echo "a is executed";
10. b();
11. }
12. a();
13. ?>
1.<?php
2.function sum($x, $y)
3.{
4. $z = $x + $y;
5. return $z;
6.}
7.echo "5 + 10 = " . sum(7,13) . "<br>";
8.echo "7 + 13 = " . sum(2,4) . "<br>";
9.echo "2 + 4 = " . sum(5,10);
10. ?>
a)
5 + 10 = 15
2+4=6
7 + 13 = 20
b)
7 + 13 = 20
5 + 10 = 15
2+4=6
c)
5 + 10 = 15
7 + 13 = 20
2+4=6
d)
5 + 10 = 20
7 + 13 = 6
2 + 4 = 15
View Answer
Answer: d
Explanation: The function calls are jumbled.
5. What will be the output of the following PHP code?
1.<?php
2.function addFive($num)
3.{
4. $num += 5;
5.}
6.function addSix(&$num)
7.{
8. $num += 6;
9.}
10. $orignum = 10;
11. addFive( &$orignum );
12. echo "Original Value is $orignum<br />";
13. addSix( $orignum );
14. echo "Original Value is $orignum<br />";
15. ?>
a)
Original Value is 15
Original Value is 21
b)
Original Value is 15
Original Value is 21
c)
Original Value is 15
Original Value is 15
1.<?php
2.function addFunction($num1, $num2)
3.{
4. $sum = $num1 + $num2;
5. return $sum;
6.}
7.$return_value = addFunction(10, 20);
8.echo "Returned value from the function : $return_value"
9.?>
1.<?php
2.function sayHello()
3.{
4. echo "HelloWorld<br />";
5.}
6.$function_holder = "sayHello";
7.$function_holder();
8.?>
a) No Output
b) Error
c) sayHello
d) HelloWorld
View Answer
Answer: d
Explanation: It is possible to assign function names as strings to variables and then treat
these variables exactly as you would the function name itself.
1.<?php
2.function one()
3.{
4. echo " this works";
5. function two()
6. {
7. echo "this too works";
8. }
9.}
10. one();
11. two();
12. ?>
a) error
b) this works
c) this worksthis too works
d) this works this too works
View Answer
Answer: c
Explanation: Two is declared in one and is called after one. Hence it works.
9. What will be the output of the following PHP code?
1.<?php
2.function do($myString)
3.{
4. echo strpos($myString, "donkey",0);
5.}
6.do("The donkey looks like a horse.");
7.?>
a) 4
b) 5
c) 2
d) None of the mentioned
View Answer
Answer: a
Explanation: Donkey starts from position 4 in string.
1.<?php
2.function one()
3.{
4. define("const","I am awesome!");
5. echo constant("const");
6.}
7.one();
8.?>
a) I am awesome!!
b) const
c) const, I am awesome!!
d) “const”,”I am awesome!”
View Answer
Answer: a
1. <?php
2. function calc($price, $tax="")
3. {
4. $total = $price + ($price * $tax);
5. echo "$total";
6. }
7. calc(42);
8. ?>
a) Error
b) 0
c) 42
d) 84
View Answer
Answer: c
Explanation: You can designate certain arguments as optional by placing them at the end of
the list and assigning them a default value of nothing.
advertisement
1. <?php
2. function a()
3. {
4. function b()
5. {
6. echo 'I am b';
7. }
8. echo 'I am a';
9. }
10. a();
11. a();
12. ?>
a) I am b
b) I am bI am a
c) Error
d) I am a Error
View Answer
Answer: d
Explanation: This will be the output- I am a Fatal error: Cannot redeclare b()
1. <?php
2. function a()
3. {
4. function b()
5. {
6. echo 'I am b';
7. }
8. echo 'I am a';
9. }
10. b();
11. a();
12. ?>
a) I am b
b) I am bI am a
c) Error
d) I am a Error
View Answer
Answer: c
Explanation: This will be the output- Fatal error: Call to undefined function b(). You cannot
call a function which is inside a function without calling the outside function.
4. What will be the output of the following PHP code?
1. <?php
2. $op2 = "blabla";
3. function foo($op1)
4. {
5. echo $op1;
6. echo $op2;
7. }
8. foo("hello");
9. ?>
a) helloblabla
b) error
c) hello
d) helloblablablabla
View Answer
Answer: c
Explanation: If you want to put some variables in function that was not passed by it, you
must use “global”. Inside the function type global $op2.
1. <?php
2. function foo($msg)
3. {
4. echo "$msg";
5. }
6. $var1 = "foo";
7. $var1("will this work");
8. ?>
a) error
b) $msg
c) 0
d) will this work
View Answer
Answer: d
Explanation:It is possible to call a function using a variable which stores the function name.
1. <?php
2. echo "chr(52)";
3. ?>
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: d
Explanation: The chr() function returns a character from the specified ASCII value. Since
the ASCII value of 4 is 52, thus 4 was displayed.
1. <?php
2. echo ord ("hi");
3. ?>
a) 106
b) 103
c) 104
d) 209
View Answer
Answer: c
Explanation: The ord() function returns the ASCII value of the first character of a string. The
ASCII value of h is 104, thus 104 was displayed.
1. <?php
2. echo(atan(0.50));
3. ?>
a) 0.11845976421345
b) 0.23568451142521
c) 0.46364760900081
d) 1
View Answer
Answer: c
Explanation: The atan() function returns the arc tangent of arg as a numeric value between
-Pi/2 and Pi/2 radians.
1. <?php
2. define("GREETING","Hello you! How are you today?");
3. echo constant("GREETING");
4. ?>
a) 1
b) 0
c) 3
d) 4
View Answer
Answer: b
1.<?php
2.for ($i = 0; 0; $i++)
3.{
4. print"i";
5.}
6.?>
a) infinite loop
b) 0
c) no output
d) error
View Answer
Answer: c
Explanation: The condition of the loop is always false 0.
advertisement
1.<?php
2.for ($i = 0; $i < 5; $i++)
3.{
4. for ($j = $i; $j > 0; $i--)
5. print $i;
6.}
7.?>
a) infinite loop
b) 0 1 2 3 4 5
c) 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5
d) no output
View Answer
Answer: a
Explanation: In the second loop j value is not being changed.
a) infinite loop
b) 0 1 2 3 4 5
c) 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5
d) no output
View Answer
Answer: d
Explanation: The second loop does not execute as the check condition is always false.
1.<?php
2.$user = array("Ashley", "Bale", "Shrek", "Blank");
3.for ($x = 0; $x < count($user); $x++)
4.{
5. if ($user[$x] == "Shrek")
6. continue;
7. printf ($user[$x]);
8.}
9.?>
a) AshleyBaleBlank
b) AshleyBale
c) AshleyBaleShrek
d) No output
View Answer
Answer: a
Explanation: Only the Shrek is skipped due to the continue statement.
1.<?php
2.$user = array("Ashley", "Bale", "Shrek", "Blank");
3. for ($x=0; $x < count($user) - 1; $x++)
4. {
5. if ($user[$x++] == "Shrek")
6. continue;
7. printf ($user[$x]);
8. }
9.?>
a) AshleyBaleBlank
b) Bale
c) AshleyShrek
d) BaleBlank
View Answer
Answer: a
Explanation: Only Bale is printed as $x++ is done before printing and then checked.
1.<?php
2.$user = array("Ashley", "Bale", "Shrek", "Blank");
3.for ($x = 0; $x < count($user); $x)
4.{
5. if ($user[$x++] == "Shrek")
6. continue;
7. printf ($user[$x]);
8.}
9.?>
a) AshleyBaleBlank
b) BaleShrek
c) AshleyBlank
d) Bale
View Answer
Answer: b
Explanation: x is incremented only inside loop i the if condition.
1.<?php
2.for ($i = 0; $i % ++$i; $i++)
3.{
4. print"i";
5.}
6.?>
a) error
b) infinite loop
c) no output
d) 0
View Answer
Answer: b
Explanation: Loop condition is true as i%(i+1) is a float non zero value in php.
1.<?php
2.for ($i = 0; $i < 5; $i++)
3.{
4. for(; $i < 5; $i++)
5. print"i";
6.}
7.?>
a) iiiii
b) infinite loop
c) iiiiiiiiiiiiiiiiiiiiiiiii
d) no output
View Answer
Answer: a
Explanation: The i value is changed in the inner loop and reaches five, thus does not
execute the second outer loop.
1.<?php
2.$a = array("hi", "hello", "bye");
3.foreach ($a as $value)
4.{
5. if (count($a) == 2)
6. print $value;
7.}
8.?>
a) hihellobye
b) infinite loop
c) hihello
d) no output
View Answer
Answer: d
Explanation: As count($a) returns 3 the condition is always false.
1.<?php
2.$a = array("hi", "hello", "bye");
3.for (;count($a) < 5;)
4.{
5. if (count($a) == 3)
6. print $a;
7.}
8.?>
a) ArrayArrayArrayArrayArrayArray….infinitely
b) (“hi”,”hello”,”bye”)(“hi”,”hello”,”bye”)(“hi”,”hello”,”bye”)(“hi”,”hello”,”bye”)…infinitely
c) hihellobyehihellobyehihellobyehihellobyehihellobyehihellobye…..infinitely
d) no output
View Answer
Answer: a