Grade – 11 – Computer Science – Web Development: Advanced Full-Stack Applications – Multiple Choice Questions

Multiple Choice Questions

Web Development: Advanced Full-Stack Applications

Topic: HTML and CSS
Grade: 11

Questions:
1. Which of the following CSS selectors will select all the

elements that are direct children of a

element?
a) div p
b) div > p
c) div + p
d) div ~ p

Answer: b) div > p
Explanation: The \”>\” selector selects only the direct children of an element. So, div > p will select all the

elements that are direct children of a

element. For example, if we have the following HTML code:

This is a direct child paragraph.

This is not a direct child paragraph.

The selector div > p will only select the first

element.

2. Which of the following CSS properties is used to add space between the content and border of an element?
a) margin
b) padding
c) border-spacing
d) border-width

Answer: b) padding
Explanation: The padding property is used to add space between the content of an element and its border. It affects the space inside the element. For example, if we have a div with a border and padding:
div {
border: 1px solid black;
padding: 10px;
}
The padding will create a 10px space between the content and the border of the div.

Topic: JavaScript
Grade: 11

Questions:
1. What will be the output of the following code snippet?
var x = 5;
console.log(x++ + ++x);
a) 10
b) 11
c) 12
d) 13

Answer: d) 13
Explanation: The expression x++ + ++x is evaluated from left to right. Initially, x is 5. In the first part of the expression, x++ returns the original value of x (5) and then increments it to 6. In the second part, ++x increments x to 7 and returns the new value (7). Therefore, the expression becomes 5 + 7 = 12. The console.log statement outputs the final value of the expression, which is 12.

2. Which of the following array methods can be used to remove elements from an array and replace them with new elements?
a) pop()
b) shift()
c) splice()
d) slice()

Answer: c) splice()
Explanation: The splice() method can be used to remove elements from an array and replace them with new elements. It takes three parameters: the starting index from where to remove/replace, the number of elements to remove, and the elements to add. For example:
var fruits = [\”apple\”, \”banana\”, \”orange\”];
fruits.splice(1, 1, \”grape\”, \”melon\”);
The above code will remove one element at index 1 (\”banana\”) and replace it with \”grape\” and \”melon\”. The resulting array will be [\”apple\”, \”grape\”, \”melon\”, \”orange\”].

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
error: Content cannot be copied. it is protected !!
Scroll to Top