07/01/2020

Cascading Style Sheet | Super and final keyword :Studywow

 Studywow: Topics= 1.Cascading Style Sheet, 2.Super and final keyword in java.
Read more topics of Java to (click here).


Q1. Define text styling in HTML? or What is Cascading Style Sheet ?

Ans. CSS (Cascading Style Sheet) is used to style HTML elements. CSS can be added to HTML in the following ways:
Inline : using the style attribute in HTML elements.
Internal : using the <style> element in the <head> section.
External : using an external CSS file.

The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files.
However, in this HTML tutorial we will introduce you to CSS using the style attribute. This is done to simplify the examples. It also makes it easier for you to edit the code and try it yourself.

In-line

In-line styles are plonked straight into the HTML tags using the style attribute.
Syntax: <p style="color: red">text</p>
This will make that specific paragraph red. But, if you remember, the best-practice approach is that the HTML should be a stand-alone, presentation free document and so in-line styles should be avoided wherever possible.

Internal

Embedded or internal, styles are used for the whole page. Inside the head element, the style tags surround all of the styles for the page.
For example:
<html>
<head>
<title> CSS Example</title>
<style>
P {
color: red;
}
a {
color: blue;
}
</style>
</head>
</html>


Q2. Super and final keyword in Java ?

Ans. 1. Super keyword

It is used to access super class variables and methods by subclass object when they are overridden by subclass. Super keyword is used by the programmer to call super class variables and methods by subclass object when they are overridden by subclass. It has the following usages:
(a) Super with Variables: Super keyword is used to call the superclass.
(b) Super with Methods: Similar to variable overriding, a method also can be overridden. If the super class and subclass have the same method (with same parameters and return type), we say super class method is overridden by subclass. If overridden, the subclass object will call its own method. To call super class method also, the subclass uses super keyword.

2. Final keyword

It is used in three places in Java with different jobs:
• Final variable cannot be reassigned (like const of C/C++).
• Final method cannot be overridden.
• Final class cannot be extended by other classes.
The final keyword works differently when called with variables, methods and classes. But final conveys a meaning that something cannot happen.
(a) Final with Variables: A final variable works as a constant that cannot be reassigned.
(b) Final with Methods: Sometimes, the super class may think of that its methods cannot be overridden by subclass. Then, super class declares those methods as final. With non-final methods, the subclass is at liberty to override or not.
(c) Final with Classes: If the programmer does not like a class not to be inherited (or extended) by other classes, then declares it as final. That is, a final class can be inherited.



[Topics= Cascading Style Sheet, Super and final keyword in java.]
End.


Join us on Facebook and Twitter  to get the latest study material. You can also ask us any questions.
Facebook = @ studywow
(click on it or search "studywow" on facebook)
Twitter = @ studywow
(click on it or search "studywow" on Twitter)
Email= studywow.com@gmail.com
Send us your query anytime!


External website links:


1. Cascading Style Sheet (click here).
2. Super and final keyword in java (click here).

[Topics= Cascading Style Sheet, Super and final keyword in java.]