0% found this document useful (0 votes)
17 views

Css and Java Viva More Questions 2

Uploaded by

computerhomenk69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Css and Java Viva More Questions 2

Uploaded by

computerhomenk69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

SOME MORE QUESTIONS FOR

KNOWLEDGE

CSS
⏬⏬⏬⏬⏬⏬⏬
⏬⏬⏬⏬⏬⏬
Q1. What is the full form of CSS?
Answer - Cascading Style Sheets.

Q2. What is the use of the <style> tag?


Answer - It is used to write internal CSS inside
an HTML document.

Q3. What is an ID selector in CSS?


Answer - An ID selector is used to style a
specific element using #idName.

Q4. What is a Class selector in CSS?


Answer - A Class selector is used to style
multiple elements using .className.

Q5. How do you apply the same style to


multiple selectors?
Answer - By separating selectors with commas.
Example: h1, p { color: red; }
Q6. What is the difference between inline and
block elements?
Answer - Inline elements do not start on a new
line, while block elements start on a new line.

Q7. What does the color property do in CSS?


Answer - It changes the text color of an
element.

Q8. How can you make text italic in CSS?


Answer - Use the font-style: italic;
property.

Q9. What is the purpose of the display


property in CSS?
Answer - It defines how an element is displayed
(e.g., block, inline, none).
Q10. What is the text-align property used
for?
Answer - It is used to align text (e.g., left, right,
center).

Q11. What is the default value of the position


property?
Answer - The default value is static.

Q12. How do you apply a background image in


CSS?
Answer - Use the background-image property.

Q13. What is the difference between absolute


and relative positioning?
Answer -
 absolute: Positions an element relative to
its nearest positioned ancestor.
 relative: Positions an element relative to
its normal position.
Q14. How do you style a link that has been
visited?
Answer - Use the :visited pseudo-class.

Q15. What is the purpose of the border-radius


property?
Answer - It is used to make the corners of a
border rounded.

Q16. How can you set a shadow for an element


in CSS?
Answer - Use the box-shadow property.

Q17. What is the difference between max-width


and min-width?
Answer -
 max-width: Sets the maximum width of an
element.
 min-width: Sets the minimum width of an
element.
Q18. What is the opacity property in CSS?
Answer - It controls the transparency of an
element (value between 0 and 1).

Q19. How do you make a list horizontal in


CSS?
Answer - Use display: inline; for the list
items.

Q20. What is the difference between relative


and fixed positioning?
Answer -
 relative: Element is positioned relative to
its normal location.
 fixed: Element is positioned relative to the
viewport and doesn’t move when scrolled.

Q21. What is the hover pseudo-class used for?


Answer - It applies a style when the user hovers
over an element.
Q22. How do you set a specific font in CSS?
Answer - Use the font-family property.

Q23. What is the purpose of the outline


property?
Answer - It draws a line outside the element’s
border without affecting its size.

Q24. How do you center a div in CSS?


Answer - Use margin: auto; with a specified
width.

Q25. What is the use of the float property?


Answer - It allows elements to be positioned to
the left or right of a container.
Q26. What is the difference between em and px
units in CSS?
Answer -
 em: Relative to the parent element’s font
size.
 px: Absolute size in pixels.

Q27. What is a pseudo-element in CSS?


Answer - It styles specific parts of an element.
Example: ::first-letter.

Q28. How do you hide an element but keep its


space on the page?
Answer - Use visibility: hidden;.

Q29. What is a responsive web design?


Answer - A design that adjusts to different
screen sizes.
Q30. How do you make text uppercase in CSS?
Answer - Use the text-transform: uppercase;
property.

Q31. What is the purpose of the overflow


property?
Answer - It handles how content is displayed
when it overflows the container.

Q32. How do you create a fixed navigation bar?


Answer - Use position: fixed; for the nav
bar.

Q33. What is the difference between inline and


inline-block?
Answer -
 inline: Does not allow setting width and
height.
 inline-block: Allows setting width and
height.
Q34. What is the clip-path property?
Answer - It is used to create custom shapes for
elements.

Q35. How do you style the first line of a


paragraph?
Answer - Use the ::first-line pseudo-
element.

Q36. What is the transition property in CSS?


Answer - It adds smooth effects when
properties change.

Q37. How do you add space between elements?


Answer - Use the margin property.
Q38. What is the difference between padding
and border?
Answer -
 padding: Space inside the element.
 border: The line around the element.

Q39. What is the use of line-height?


Answer - It sets the space between lines of text.

Q40. How do you underline text in CSS?


Answer - Use the text-decoration:
underline; property.

Q41. What is the flexbox in CSS?


Answer - Flexbox is used to design flexible and
responsive layouts.
Q42. How do you make an element
transparent?
Answer - Use opacity: 0;.

Q43. What is the cursor property used for?


Answer - It changes the mouse pointer style.

Q44. How do you change the order of elements


using CSS?
Answer - Use the order property in Flexbox.

Q45. What are media queries?


Answer - Media queries apply styles based on
screen size or device type.
Q46. What is the use of position: sticky;?
Answer - It makes an element stick to a position
while scrolling.

Q47. How do you create animations in CSS?


Answer - Use the @keyframes rule and
animation property.

Q48. What is the difference between fixed and


sticky positioning?
Answer -
 fixed:Stays in place relative to the
viewport.
 sticky: Moves until a specified position is
reached.

Q49. What is the purpose of the grid in CSS?


Answer - It is used to create complex layouts
with rows and columns.
Q50. What is the transition-delay property?
Answer - It defines the delay before a transition
starts.

JAVA ⏬⏬⏬⏬⏬
Q1. What is Java?
Answer - Java is a high-level, object-oriented
programming language used for building
applications.

Q2. What is the difference between Java and


JavaScript?
Answer - Java is a programming language,
whereas JavaScript is a scripting language used
for web development.

Q3. What is the main() method in Java?


Answer - The main() method is the entry point
where a Java program starts execution.

Q4. What is a variable in Java?


Answer - A variable is a container used to store
data values.

Q5. What is the purpose of the


System.out.println() function in Java?
Answer - It is used to print messages or data to
the console.

Q6. What is an object in Java?


Answer - An object is an instance of a class that
represents a real-world entity.

Q7. What is a class in Java?


Answer - A class is a blueprint for creating
objects that define properties and behaviors.

Q8. What is the use of the new keyword in


Java?
Answer - The new keyword is used to create
new objects or instances of a class.
Q9. What is a constructor in Java?
Answer - A constructor is a special method used
to initialize objects.

Q10. What is the difference between int and


Integer in Java?
Answer - int is a primitive data type, while
Integer is a wrapper class for the int type.

Q11. What is an array in Java?


Answer - An array is a collection of elements of
the same type stored in a single variable.

Q12. What is the difference between == and


equals() in Java?
Answer - == compares object references, while
equals() compares the content of objects.
Q13. What is method overloading in Java?
Answer - Method overloading is defining
multiple methods with the same name but
different parameters.

Q14. What is inheritance in Java?


Answer - Inheritance allows one class to inherit
the properties and behaviors of another class.

Q15. What is polymorphism in Java?


Answer - Polymorphism allows methods to take
multiple forms, like method overloading and
overriding.

Q16. What is encapsulation in Java?


Answer - Encapsulation is the concept of
wrapping data (variables) and methods into a
single unit, usually a class.
Q17. What is abstraction in Java?
Answer - Abstraction hides complex
implementation details and shows only the
essential features of an object.

Q18. What is the this keyword in Java?


Answer - The this keyword refers to the current
object instance.

Q19. What is the super keyword in Java?


Answer - The super keyword refers to the
parent class of the current object.

Q20. What is a try-catch block in Java?


Answer - A try-catch block is used for handling
exceptions or errors in Java programs.
Q21. What is the difference between ArrayList
and LinkedList in Java?
Answer - ArrayList is a dynamic array, while
LinkedList is a doubly linked list.

Q22. What is the purpose of the final keyword


in Java?
Answer - The final keyword is used to declare
constants, prevent method overriding, and
prevent inheritance.

Q23. What is a package in Java?


Answer - A package is a namespace that groups
related classes and interfaces.

Q24. What is the void keyword in Java?


Answer - The void keyword indicates that a
method does not return any value.
Q25. What is a static method in Java?
Answer - A static method belongs to the class,
not the instance, and can be called without
creating an object.

Q26. What is a constructor overloading in


Java?
Answer - Constructor overloading allows a
class to have multiple constructors with
different parameters.

Q27. What is the String class in Java?


Answer - The String class is used to store a
sequence of characters.

Q28. What is the difference between String and


StringBuilder?
Answer - String is immutable (cannot be
changed), while StringBuilder is mutable (can
be changed).
Q29. What is the equals() method in Java?
Answer - The equals() method is used to
compare two objects for equality.

Q30. What is an interface in Java?


Answer - An interface is a contract that defines
methods without providing their
implementation.

Q31. What is the difference between an


interface and an abstract class in Java?
Answer - An interface only declares methods,
while an abstract class can have both declared
and implemented methods.

Q32. What is the instanceof keyword in Java?


Answer - The instanceof keyword checks if an
object is an instance of a specified class or
subclass.
Q33. What is a return statement in Java?
Answer - The return statement is used to exit a
method and optionally return a value.

Q34. What is the difference between throw and


throws in Java?
Answer - throw is used to throw an exception
explicitly, while throws is used to declare
exceptions in the method signature.

Q35. What is the default keyword in Java


interfaces?
Answer - The default keyword allows an
interface to have method implementations.

Q36. What is a Set in Java?


Answer - A Set is a collection that does not
allow duplicate elements.
Q37. What is a Map in Java?
Answer - A Map is a collection of key-value
pairs where each key is unique.

Q38. What is the Collections class in Java?


Answer - The Collections class provides utility
methods for working with collections, like
sorting and reversing.

Q39. What is the clone() method in Java?


Answer - The clone() method creates a copy of
an object.

Q40. What is the Thread class in Java?


Answer - The Thread class allows the execution
of multiple tasks concurrently.
Q41. What is the difference between wait() and
sleep() in Java?
Answer - wait() releases the lock on an object,
while sleep() pauses the execution of a thread
for a specified time.

Q42. What is the Runnable interface in Java?


Answer - The Runnable interface represents a
task that can be executed by a thread.

Q43. What is the purpose of synchronized


keyword in Java?
Answer - The synchronized keyword ensures
that only one thread can access a method or
block of code at a time.
Q44. What is the difference between abstract
and interface in Java?
Answer -
 abstract: Can have both abstract and
concrete methods.
 interface: Can only have abstract methods
(until Java 8, which added default
methods).

Q45. What is a package in Java?


Answer - A package is a namespace that groups
related classes and interfaces.

Q46. What is a method signature in Java?


Answer - A method signature consists of the
method name and parameter types, but not the
return type.
Q47. What is a char data type in Java?
Answer - The char data type stores a single 16-
bit Unicode character.

Q48. What is the use of import keyword in


Java?
Answer - The import keyword is used to bring
in classes or entire packages into a Java
program.

Q49. What is the difference between continue


and break in Java?
Answer -
 continue: Skips the current iteration of a
loop.
 break: Exits the loop completely.
Q50. What is the Math class in Java?
Answer - The Math class provides methods for
performing mathematical operations like
square root, power, etc.

ALL THE BEST MY LITTLE CHUZI!

-Nishant

You might also like