Answer of Questions
Answer of Questions
Java Questions
16. Which of the following is a valid declaration of a char in Java?
A) char c = '\u0061';
B) char c = 'ab';
C) char c = "a";
D) char c = 65;
Answer: A) char c = '\u0061';
17. What is the output of the following Java code?
java
Copy code
int a = 10;
int b = 20;
System.out.println(a++ + ++b);
A) 30
B) 31
C) 32
D) 33
Answer: C) 32
18. Which of the following is not a feature of Java?
A) Platform-independent
B) Object-oriented
C) Procedural
D) Dynamic
Answer: C) Procedural
19. Which method must be implemented by all threads in Java?
A) start()
B) stop()
C) run()
D) execute()
Answer: C) run()
20. What is the default value of an uninitialized boolean variable in Java?
A) true
B) false
C) 0
D) null
Answer: B) false
21. What does the 'static' keyword mean in Java?
A) It allows a method to be overridden.
B) It allows a method or variable to be accessed without instantiating an object.
C) It prevents a variable from being changed.
D) It allows the method to be accessed by derived classes.
Answer: B) It allows a method or variable to be accessed without instantiating
an object.
22. Which of the following is not a valid Java exception?
A) NullPointerException
B) IOException
C) FileNotFoundException
D) ArrayIndexOutOfBoundException
Answer: D) ArrayIndexOutOfBoundException (Correct one is
ArrayIndexOutOfBoundsException)
23. What will be the output of the following Java code?
java
Copy code
String str = "Hello World";
System.out.println(str.substring(6, 11));
A) Hello
B) World
C) World!
D) ello
Answer: B) World
24. Which of the following collections is synchronized in Java?
A) ArrayList
B) LinkedList
C) Vector
D) HashMap
Answer: C) Vector
25. Which package is automatically imported into every Java program?
A) java.io
B) java.util
C) java.lang
D) java.net
Answer: C) java.lang
HTML Questions
26. Which HTML tag is used to define a table row?
A) <table>
B) <td>
C) <tr>
D) <th>
Answer: C) <tr>
27. Which HTML attribute is used to specify a unique identifier for an element?
A) id
B) class
C) name
D) style
Answer: A) id
28. Which HTML tag is used to define an internal style sheet?
A) <style>
B) <script>
C) <link>
D) <head>
Answer: A) <style>
CSS Questions
29. What is the correct CSS syntax to make all paragraphs bold?
A) <p style="font-weight: bold">
B) p {font-weight: bold;}
C) p {text-size: bold;}
D) <p style="text-size: bold
4o
What is the correct CSS syntax to make all paragraphs bold? A) <p style="font-weight: bold"> B) p
{font-weight: bold;} C) p {text-size: bold;} D) <p style="text-size: bold
To make all paragraphs bold using CSS, the correct syntax is:
B) p {font-weight: bold;}
Explanation:
A) <p style="font-weight: bold">: This is incorrect because it's HTML with inline
CSS, not a CSS rule for styling all paragraphs globally.
B) p {font-weight: bold;}: This is correct. It uses a CSS rule to set the font-weight
property of all <p> elements to bold.
C) p {text-size: bold;}: This is incorrect because text-size is not a valid CSS
property. The correct property for making text bold is font-weight.
D) <p style="text-size: bold">: This is incorrect for two reasons: text-size is not a
valid property, and it is using inline HTML styling instead of a CSS rule.
In CSS, the font-weight property is used to control the boldness of text. Setting it to bold makes
the text bold.
4o
give one unique mcq question of CSS
Here's a unique CSS MCQ question:
Question:
Which CSS pseudo-class would you use to style a link only when the user is actively clicking
on it?
A) :hover
B) :active
C) :focus
D) :visited
Answer:
B) :active
Explanation:
A) :hover: This pseudo-class applies when the user designates an element (such as a link)
by pointing at it with a pointing device, but does not activate it.
B) :active: This pseudo-class applies while an element (such as a link) is being activated
by the user (for example, between the times the mouse button is pressed and released).
C) :focus: This pseudo-class applies while an element (such as a form input) has focus (is
ready to receive input from the user).
D) :visited: This pseudo-class applies once the link has been visited.
4o