CSS: div id VS. div class

what’s the difference between DIV class and DIV Id when it comes to css ?

ids must be unique where as class can be applied to many things. In CSS, ids look like#elementID and class elements look like .someClass

In general, use id whenever you want to refer to a specific element and class when you have a number of things that are all alike. For instance, common id elements are things like header,footer, sidebar. Common class elements are things like highlight or external-link.

It’s a good idea to read up on the cascade and understand the precedence assigned to various selectors: http://www.w3.org/TR/CSS2/cascade.html

The most basic precedence you should understand, however, is that id selectors take precedence over class selectors. If you had this:

<p id="intro" class="foo">Hello!</p>

and:

#intro { color: red }
.foo { color: blue }

The text would be red because the id selector takes precedence over the class selector.

Javatip : Why do we have only public static final variables in interfaces?

An interface defines a protocol of behavior and not how you should be implemented. A class that implements an interface adheres to the protocol defined by that interface.

All fields declared within an interface are implicity public, static, and final. Why?

  • Any implementations can change value of fields if they are not defined as final. Then they would become a part of the implementation.An interface is a pure specification without any implementation.
  • If they are static, then they belong to the interface, and not the object, nor the run-time type of the object.
  • An interface provide a way for the client to interact with the object. If variables were not public, the clients would not have access to them.

In general, a field declaration may include the following modifiers: public, protected, private, final, static, transient, volatile. But only public, final, and static are permitted for interface’s variable.

Every field declaration in the body of an interface is implicitly public, static, and final. It is permitted to redundantly specify any or all of these modifiers for such fields. Every field in the body of an interface must have an initialization expression, which need not be a constant expression. The variable initializer is evaluated and the assignment performed exactly once, when the interface is initialized.