1) Which of the following tag is used to embed css in html page?
a) <css>
b) <!DOCTYPE html>
c) <script>
d) <style>
2) Which of the following CSS selectors are used to specify a group of elements?
a) tag
b) id
c) class
d) both class and tag
3) Which of the following type of HTML tag is used to define an internal style sheet?
a) <script>
b) <link>
c) <class>
d) <style>
4) Which of the following is the correct syntax to link an external style sheet in the HTML file?
a) <link rel=”stylesheet” href=”style.css” />
b) <link rel=”stylesheet” src=”style.css” />
c) <style rel=”stylesheet” src=”style.css” />
d) <style rel=”stylesheet” link=”style.css” />
5)span {
border: 1px solid red;
outline: green dotted thick;
}
a) All span elements will have a green thick border and a red outline
b) All span elements will have a red border and a green dotted outline
c) All span elements will have a outer green dotted border and an inner red border
d) All span elements will have an outer red border and inner green dotted border
6) Which of the following is an appropriate value for the overflow element?
a) scroll
b) hidden
c) auto
d) all of the mentioned
7) What is the correct syntax of doctype in HTML5?
a) </doctype html>
b) <doctype html>
c) <doctype html!>
d) <!doctype html>
8) Which of the following HTML code will make an image clickable?
a) <a href="https://www.sanfoundry.com/">Sanfoundry Home Page</a>
b) <img src="https://www.sanfoundry.com/sanfoundry-logo">
<a href="https://www.sanfoundry.com/">Sanfoundry Home Page</a>
</img>
c) <a href="https://www.sanfoundry.com/">Sanfoundry Home Page</a>
<img src="https://www.sanfoundry.com/sanfoundry-logo" />
d) <a href="https://www.sanfoundry.com/"><img src="https://www.sanfoundry.com/sanfoundry-logo" /></a>
9) Which of the following HTML tag is used to create an unordered list?
a) <ol>
b) <ul>
c) <li>
d) <ll>
10) How to insert Hyperlink in HTML Page?
a) <a href="https://www.sanfoundry.com/1000-html-questions-answers/">HTML MCQ</a>
b) <a target="https://www.sanfoundry.com/1000-html-questions-answers/" HTML Quiz />
c) <a src="https://www.sanfoundry.com/1000-html-questions-answers/">HTML Test</a>
d) <a>https://www.sanfoundry.com/1000-html-questions-answers/</a>
11) Which of the following CSS property is used to specify table borders in CSS?
a) table:border
b) table
c) border
d) none of the mentioned
12) Which of the following selector in CSS is used to select the elements that do not match the selectors?
a):! selector
b):not selector
c):empty selector
d)None of the above
13) Which of the following is correct about JavaScript?
a) JavaScript is an Object-Based language
b) JavaScript is Assembly-language
c) JavaScript is an Object-Oriented language
d) JavaScript is a High-level language
14) What will be the output of the following JavaScript code snippet?
<p id="demo"></p>
var txt1 = "Sanfoundry_";
var txt2 = "Javascriptmcq";
document.getElementById("demo").innerHTML = txt1 + txt2;
a) error
b) Sanfoundry_ Javascriptmcq
c) undefined
d) Sanfoundry_Javascriptmcq
15) What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
var js = 10;
js *= 5;
document.getElementById("demo").innerHTML = js;
</script>
a) 10
b) 50
c) 5
d) Error
16) What will be the output of the following JavaScript code?
function compare()
{
let a=2;
let b=2.0;
if(a==b)
return true;
else
return false;
}
a) false
b) true
c) compilation error
d) runtime error
17) Will the following JavaScript code work?
var js = (function(x) {return x*x;}(10));
a) Exception will be thrown
b) Memory leak
c) Error
d) Yes, perfectly
18) What will be the output of the following JavaScript code snippet?
int a=1;
if(a!=null)
return 1;
else
return 0;
a) 0
b) 1
c) compiler error
d) runtime error
19) What will be the output of the following JavaScript program?
function sanfoundry(javascript)
{
return (javascript ? “yes” : “no”);
}
bool ans=true;
console.log(sanfoundry(ans));
a) Compilation error
b) Runtime error
c) Yes
d) No
20) Which of the following methods/operation does javascript use instead of == and !=?
a) JavaScript uses equalto()
b) JavaScript uses equals() and notequals() instead
c) JavaScript uses bitwise checking
d) JavaScript uses === and !== instead
21) In the JavaScript, which one of the following is not considered as an error ________
a)Missing of semicolons
b)Syntax error
c)Division by zero
d)Missing of Bracket
22) The following is a web-page :
<html>
<head> <title>JavaScript</title> </head>
<body bgcolor=""#0000ff"">
<script language=""JavaScript"">
<!-- document.write(""<h1> hello world </h1>""); //-->
</script>
</body>
</html>
When the above web page is loaded into a browser, what will happen?
a)The body of the web page will not contain any text
b)The body of the web page will contain the text “hello world” as an H1 heading
c)The background color of the web page will be green
d)document.write("<h1> hello world </h1 >”); is a comment.
23)The _______ method of an Array object adds and/or removes elements from an array.
a)Reverse
b)Shift
c)Slice
d)Splice
24) What will be the output of the following JavaScript code?
const obj1 = {
property1: 2
};
Object.seal(object);
obj1.property1 =4;
console.log(obj1.property1);
delete obj1.property1;
a)2
b)4
c)Error
d)Undefined
25) What will be the output of the following JavaScript code?
const prototype1 = {};
const object1 Object.create(prototype1);
console.log(Object.getPrototypeof(object1) = = = prototype1);
a)true
b)false
c)error
d)0
26) What will be the function of the following JavaScript code?
var scope = "global scope";
function checkscope() {
var scope = "local scope";
function f()
{
return scope;
}
return f;
a)Returns value null
b)Returns exception
c)Returns the value in scope
d)Shows an error message
27) What will be the output of the following JavaScript code?
person var person=
name: "Rahul",
getName: function()
{
nreturn this.name;
}
var unboundName person.getName;
var boundName unboundName.bind(person);
document.writeln(boundName());
a)runtime error;
b)compilation error
c)Rahul
d)Undefined
28) What will be the output of the following JavaScript code?
function output(option){
return (option ? "yes" : "no");
}
bool ans = true;
console.log(output(ans));
a)Yes
b)No
c)Runtime error
d)Compilation error
29) What is the color of an unvisited link?
a)red
b)blue
c)purple
d)green
30. Headings of table lies inside . . . . . . . .
a)<thead>
b)<tfoot>
c)<th>
d)<tbody>
31. Which of the following methods can be used to display data in some form using Javascript?
a)document.write()
b)console.log()
c)window.alert()
d)All of the above
32. What will be the output of the following code snippet?
<script type="text/javascript">
a = 5 + "9";
document.write(a);
</script>
a)Compilation Error
b)14
c)Runtime Error
d)59
33. What will be the output of the following code snippet?
<script type="text/javascript" language="javascript">
var a = "Scaler";
var result = a.substring(2, 4);
document.write(result);
</script>
a)al
b)ale
c)cal
d)caler
34. What will be the output of the following code snippet?
let sum = 0;
const a = [1, 2, 3];
a.forEach(getSum);
print(sum);
function getSum(ele) {
sum += ele;
}
a)6
b)1
c)2
d)None of the above
35. What will be the output of the following code snippet?
a = [1, 2, 3, 4, 5];
print(a.slice(2, 4));
a)3, 4
b)2, 3
c)3, 4, 5
d)2, 3, 4
36. What will be the output of the following code snippet?
const example = ({ a, b, c }) => {
console.log(a, b, c);
};
example(0, 1, 2);
a)0 1 2
b)0 Undefined Undefined
c)Undefined Undefined Undefined
d)None of the above
37. What will be the output of the following code snippet?
let a = [1, 2, 3, 4, 5, 6];
var left = 0, right = 5;
var found = false;
var target = 5;
while(left <= right) {
var mid = Math.floor((left + right) / 2);
if(a[mid] == target) {
found = true;
break;
}
else if(a[mid] < target) {
left = mid + 1;
}
else {
right = mid - 1;
}
}
if(found) {
print("YES");
}
else {
print("NO");
}
a)YES
b)NO
c)Syntax Error
d)None of the above
38. What will be the output of the following code snippet?
const obj1 = {Name: "Hello", Age: 16};
const obj2 = {Name: "Hello", Age: 16};
print(obj1 === obj2);
a)true
b)false
c)Undefined
d)None of the above
39. How do we write a comment in javascript?
a)/* */
b)//
c)#
d)$ $
40. What will be the output of the following code snippet?
const obj1 = {first: 20, second: 30, first: 50};
console.log(obj1);
a){first: 20, second: 30}
b){first: 50, second: 30}
c){first: 20, second: 30, first: 50}
d)Syntax Error