–
HTML & CSS ------------------
1. Which of the following tag is used for inserting the largest heading in
HTML?
1. <h3>
2. <h1>
3. <h5>
4. <h6>
2. Which of the following tag is used to make the underlined text?
1. <i>
2. <ul>
3. <u>
4. <pre>
3. Which of the following is the container for <tr>, <th>, and <td> ?
1. <data>
2. <table>
3. <group>
4. All of the above
4. In HTML5, which of the following tag is used to initialize the document
type?
1. <Doctype HTML>
2. <\Doctype html>
3. <Doctype>
4. <!DOCTYPE html>
5. Which of the following is the correct syntax for referring the external
style sheet?
1. <style src = example.css>
2. <style src = "example.css" >
3. <stylesheet> example.css </stylesheet>
4. <link rel="stylesheet" type="text/css" href="example.css">
6. How to select the elements with the class name "example"?
1. example
2. #example
3. .example
4. Class example
7. Which of the following is the correct syntax to select the p siblings of a
div element?
1. p
2. div + p
3. div p
4. div ~ p
8. Which type of CSS is used in the below code?
<p style = "border:2px solid red;">
1. Inline CSS
2. Internal CSS
3. External CSS
4. None of the above
9. What is the default display property for a `<div>` element in CSS?
1. Block
2. inline
3. inline-block
4. flex
10. What is the purpose of the CSS property “border-radius”?
1. Sets the width of the element’s border
2. Adds a shadow to the element’s border
3. Rounds the corners of the element’s border
4. Changes the colour of the element’s border
11. How can you apply a style to an element with the id “header” in
CSS?
— A. #header
— B. .header
— C. element:header
— D. header:
12. How do you center an element horizontally in CSS?
— A. text-align: center;
— B. margin: auto;
— C. align: center;
— D. horizontal-align: center
13. Which CSS pseudo-class is used to select and style an element when
the mouse is over it?
— A. :hover
— B. :active
— C. :focus
— D. :visited
14. What does the CSS property “position: relative;” do?
— A. Positions the element absolutely
— B. Positions the element relative to its normal position
— C. Centers the element horizontally
— D. Floats the element to the right
15. How can you apply a style to every second row of a table in CSS?
— A. tr:nth-child(even)
— B. tr:nth-child(odd)
— C. tr:nth-row(2)
— D. tr:nth-row(odd)
16. The href attribute in the link tag specifies the:
A. Destination of a link.
B. Link
C. Hypertext
D. None of the above
17. What are meta tags used for?
A. To store information usually relevant to browsers and search
engines
B. To only store information usually relevant to browsers
C. To only store information about search engines
D. To store information about external links
18. Which of the following is used to increase the row height in CSS
grids?
A. cell spacing
B. Cell padding
C. Row span
D. Col span
19. Which of the following are attributes of Font Tag?
A. Face
B. Color
C. Size
D. All of Above
JAVA MCQs
1. Which of the following is not a valid keyword in Java?
A) transient
B) volatile
C) strictfp
D) const
2. What will be the output of the following code?
java
String s1 = "Hello";
String s2 = "Hello";
System.out.println(s1 == s2);
A) true
B) false
C) Compilation error
D) Runtime error
3. Which of the following interfaces does not belong to the
Collection framework?
A) List
B) Set
C) Map
D) Iterator
4. What is the default value of a boolean variable in Java?
A) true
B) false
C) null
D) 0
5. Which of these methods can be used to start a thread
execution in Java?
A) run()
B) start()
C) execute()
D) init()
6. What is the purpose of the final keyword in Java?
A) To declare a constant variable
B) To prevent method overriding
C) To prevent inheritance of a class
D) All of the above
7. Which exception is thrown when an application attempts to
divide by zero?
A) ArithmeticException
B) NullPointerException
C) ClassCastException
D) ArrayIndexOutOfBoundsException
8. What will be the output of the following code snippet?
java
int[] arr = {1, 2, 3, 4};
System.out.println(arr[4]);
A) 4
B) ArrayIndexOutOfBoundsException
C) null
D) Compilation error
9. Which of the following is true about the HashMap class?
A) It is synchronized.
B) It allows duplicate keys.
C) It maintains insertion order.
D) It allows null values.
10. What does the synchronized keyword do in Java?
A) It makes a method or block thread-safe.
B) It prevents method overriding.
C) It ensures that only one thread can access a resource at a
time.
D) Both A and C
11. Which of the following is not a valid way to create an
instance of a thread in Java?
A) Extending the Thread class
B) Implementing the Runnable interface
C) Using the Executor framework
D) Using an abstract class
12. What will be printed by the following code?
java
String str = "Java";
str.concat(" Programming");
System.out.println(str);
A) Java Programming
B) Java
C) Compilation error
D) Runtime error
13. Which collection class maintains elements in sorted
order?
A) ArrayList
B) HashSet
C) TreeSet
D) LinkedList
14. What is the output of this code snippet?
java
int x = 10;
if (x++ == 10 && ++x > 10)
System.out.println(x);
else
System.out.println("Not executed");
A) 11
B) Not executed
C) 12
D) Compilation error
15. Which keyword is used to prevent a class from being
subclassed?
A) final
B) static
C) abstract
D) synchronized
16. In which package is the ArrayList class located?
A) java.util
B) java.collection
C) java.array
D) java.list
17. Which method can be used to obtain the length of an
array in Java?
A) length()
B) size()
C) length[]
D ) getLength()
18. What will happen if you try to access an index that is
out of bounds in an array?
A ) The program will terminate without any message.
B ) An ArrayIndexOutOfBoundsException will be thrown.
C ) The program will return null.
D ) The program will print 'undefined'.
Answer: B ) An ArrayIndexOutOfBoundsException will be
thrown.
19. Which of these classes are part of Java's exception
hierarchy?
– A ) Throwable
– B ) Exception
– C ) RuntimeException
– D ) All of the above
20. What does this() refer to in a constructor?
– A ) The current object
– B ) The superclass constructor
– C ) The parent class
– D ) None of these