[go: up one dir, main page]

0% found this document useful (0 votes)
28 views20 pages

Css and Java Viva Questions 1

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)
28 views20 pages

Css and Java Viva Questions 1

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/ 20

CSS AND JAVA

EASY VIVA
QUESTIONS

Ok , so ye rhe aapke easy vova questions related to CSS and


JAVA , ye aapke liye bht hi easy hai and aap inhe easily yaad kr
paaenge , just be confident and ye apko bht easily yaad ho
jaeyga ! You are the best and I know you will make it very
easily ! So , lets not waste time and lets just begin!

ALL THE
BEST
CHAMPION
! 🌟🦋🦋💫

CSS⬇️
Q1. What is CSS?
Answer - CSS (Cascading Style Sheets) is used
to style HTML elements (e.g., colors, fonts,
layouts).

Q2. What are the types of CSS?


Answer - Inline, Internal, and External CSS.

Q3. What is the syntax of CSS?


Answer - `selector { property: value; }`

Q4. How do you link an external CSS file to


an HTML file?
Answer - Using the `<link>` tag inside
`<head>`. Example: `<link rel="stylesheet"
href="styles.css">`

Q5. What is the difference between `id` and


`class` in CSS?
Answer -
- `id`: Unique, uses `#`.
- `class`: Reusable, uses `.`

Q6. How can you change the background


color using CSS?
Answer - Using the `background-color`
property. Example: `body { background-
color: lightblue; }`

Q7. What is a pseudo-class in CSS?


Answer - It defines a special state of an
element. Example: `a:hover { color: red; }`
Q8. How do you make text bold in CSS?
Answer - Using `font-weight: bold;`

Q9. What property is used to change the font


size?
Answer - `font-size`. Example: `p { font-size:
16px; }`

Q10. What is the use of `margin` in CSS?


Answer - It creates space outside the
element’s border.

Q11. What is the difference between


`padding` and `margin`?
Answer -
- `Padding`: Space inside the border.
- `Margin`: Space outside the border.

Q12. What is the `z-index` property used for?


Answer - It defines the stack order of
elements.

Q13. How do you center text using CSS?


Answer - Using `text-align: center;`

Q14. What is the purpose of the `float`


property?
Answer - It positions elements to the left or
right within a container.
Q15. What is the default position value in
CSS?
Answer - `static`

Q16. How do you set a specific height and


width for an element?
Answer - Using `height` and `width`
properties. Example: `div { width: 200px;
height: 100px; }`

Q17. How can you create a border around an


element?
Answer - Using the `border` property.
Example: `div { border: 2px solid black; }`
Q18. What are media queries in CSS?
Answer - They make designs responsive by
applying styles based on screen size.

Q19. How do you apply multiple classes to


an HTML element?
Answer - Separate classes with a space.
Example: `<div class="class1 class2"></div>`

Q20. What is the purpose of `overflow` in


CSS?
Answer – It handles content overflowing its
container.

Q21. How do you hide an element using CSS?


Answer – Using `display: none;`

Q22. What is the `position` property in CSS?


Answer - It specifies how an element is
positioned in the document. Values: `static`,
`relative`, `absolute`, `fixed`.

Q23. What is the difference between `inline`


and `block` elements?
Answer -
- `Inline`: Doesn’t start on a new line (e.g.,
`<span>`).
- `Block`: Starts on a new line (e.g., `<div>`).

Q24. How can you change the color of links?


Answer - Using `color` in `a`. Example: `a
{ color: blue; }`

Q25. What is the `box model` in CSS?


Answer - It consists of `margin`, `border`,
`padding`, and `content` to define the layout
and spacing of elements.

GOOD , AB THODA PAANI PEE


LIGIEY AND AB BARI HAI JAVA
KI , LETS GO MY LITTLE
CHAMPION!🦋🦋

JAVA
Q1. What is Java?
Answer - Java is a programming language
used to create software and applications.

Q2. What is the purpose of the main()


method in Java?
Answer - The main() method is the starting
point where a Java program begins its
execution.
Q3. What is a variable in Java?
Answer - A variable is used to store data in a
program.

Q4. What are the basic data types in Java?


Answer - int, float, double, char, and
boolean.

Q5. What is the difference between int and


float?
Answer – int stores whole numbers, and
float stores numbers with decimals.
Q6. What is an object in Java?
Answer - An object is a real-world entity
created from a class.

Q7. What is a class in Java?


Answer - A class is a blueprint for creating
objects.

Q8. What is the use of the


System.out.println() statement?
Answer - It is used to print messages or data
to the screen.
Q9. What is the difference between == and =
in Java?
Answer - = is used to assign a value, and == is
used to compare values.

Q10. What is a constructor in Java?


Answer - A constructor is a special method
used to initialize an object.

Q11. What is the difference between a while


loop and a for loop?
Answer - A while loop runs based on a
condition, and a for loop runs for a specific
number of times.
Q12. What is an array in Java?
Answer - An array is a collection of similar
types of data stored in a single variable.

Q13. What is the use of the if statement in


Java?
Answer - The if statement is used to make
decisions based on conditions.

Q14. What is method overloading?


Answer - Method overloading means having
multiple methods with the same name but
different parameters.
Q15. What is inheritance in Java?
Answer - Inheritance allows a class to use the
properties and methods of another class.

Q16. What is polymorphism in Java?


Answer - Polymorphism allows a task to be
performed in different ways, like method
overloading and overriding.

Q17. What is encapsulation in Java?


Answer - Encapsulation means wrapping
data and methods into a single unit (a class).
Q18. What is abstraction in Java?
Answer - Abstraction hides unnecessary
details and shows only the essential
information.
Q19. What is the difference between break
and continue?
Answer - break stops the loop, and continue
skips the current iteration.

Q20. What is the use of the static keyword in


Java?
Answer - The static keyword is used to define
methods or variables that belong to the
class, not objects.

Q21. What is a package in Java?


Answer - A package is a group of related
classes and interfaces.

Q22. What is the difference between a String


and a StringBuilder?
Answer - A String is immutable (can’t
change), and a StringBuilder is mutable (can
change).

Q23. What is the difference between public,


private, and protected?
Answer -
public: Accessible everywhere.
private: Accessible only in the same class.
protected: Accessible in the same package
and subclasses.

Q24. What is the use of exception handling in


Java?
Answer - Exception handling is used to
manage errors in a program without
stopping its execution.

Q25. What is garbage collection in Java?


Answer - Garbage collection automatically
removes unused objects to free up memory.
YOU ARE ALL SET FOR TOMORROE! JUST
KEEP GOING ! 🦋🦋 YOU ARE TALENTED AND
BRILLIANT ! I BELIEVE IN YOU PGL!

You might also like