basic HTML :: futureX

HTML Headings


HTML headings are defined with the <h1> to <h6> tags.

Example

<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
html heading example :: futureX

HTML Paragraphs

HTML paragraphs are defined with the <p> tag.

Example

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

HTML Links

HTML links are defined with the <a> tag.

Example

<a href="http://www.futurextech.blogspot.com">This is a link</a>



Note: The link address is specified in the href attribute.


HTML Images

HTML images are defined with the <img> tag.

Example

<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXGB1U7-60jnOvecQdP_Wqk5F3kJ5OOZOwAvC0zv-vkpHpIRIUBK68VzbvpdECUHAqRJz-84xpM9hupSCiT-GrD6zpDZVn6_UozjhTF6TBKhTshuAj8TPm9RLnug7nT5szSb3p8O3WMLfY/s1600/images.jpg" width="104" height="142">


Note: The filename and the size of the image are provided as attributes.




« Previous Chapter                                                                                                                                         Next Chapter »


A package is a group of similar types of class, interfaces and sub-packages.
Package can be categorized in two form, built-in package and user-defined package. There are many built-in packages such as java.lang, awt, javax, swing, net, io, util, sql etc.
package in java :: futureX

In this page, we will have the detailed learning of creating user-defined packages.

Advantage of Package

  • Package is used to categorize the classes and interfaces so that they can be easily maintained.
  • Package providEs access protection.
  • Package removes naming collision.

Example

To compile : javac -d . Simple.java
To run       : java mypack.Simple

package com;
class Simple{
public static void main(){
System.out.println("hello java");
}
}

The -d is a switch that tells the compiler where to put the class file i.e. it represents destination. The . represents the current folder.


How to access package from another package?

  • import package.*;
  • import package.classname;
  • fully qualified name.



The import keyword is used to make the classes and interface of another package accessible to the current package.



If you use package.* then all the classes and interfaces of this package will be accessible but not subpackages.

If you import package.classname then only declared class of this package will be accessible but not subpackages.

If you use fully qualified name then only declared class of this package will be accessible. Now there is no need to import. But you need to use fully qualified name every time when you are accessing the class or interface.

package math;
public class Calc{
public static int cube(int n){return n*n*n;}
}


//import all the classes of that package

package com;
import math.*;
class Simple{
public static void main(String args[]){
System.out.println(Calc.cube(5));
}
}

//only declared class is acessible

package com;
import math.Calc;
class Simple{
public static void main(String args[]){
System.out.println(Calc.cube(5));
}
}




//without import, full qualified name

package com;
class Simple{
public static void main(String args[]){
System.out.println(math.Calc.cube(5));
}
}


Subpackages:

Package inside the package is called the subpackage. It should be created to categorize the package further. Let's take an example, Sun Microsystems has defined a package named java that contains many classes like System, String, Reader, Writer, Socket etc. These classes represent a particular group e.g. Reader and Writer classes are for Input/Output operation, Socket and ServerSocket classes are for networking etc and so on. So, Sun has subcategorized the java package into subpackages such as lang, net, io etc. and put the Input/Output related classes in io package, Server and ServerSocket classes in net packages and so on.

standard declaration:
com.companyname.packagename.classname

package com.techshakti.math;
public class subpackage{
public static int cube(int n){return n*n*n;}
}


                                          JAVA TUTORIALS HOMEPAGE
interface in java :: futureX

Interface: An interface is a blueprint of a class. It has static constants and abstract methods.
The interface is a mechanism to achieve abstraction in java. There can be only abstract methods in the interface. It is used to achieve fully abstraction and multiple inheritance in Java.

Why use Interface?

It is used to achieve fully abstraction.
By interface, we can support the functionality of multiple inheritance.
It can be used to achieve loose coupling
the java compiler converts methods of interface as public and abstract, data members as public,final and static by default.

Example :

interface Shape{
void draw();
}

class Circle implements Shape{
public void draw(){System.out.println("drawing circle");}
}

class Rectangle implements Shape{
public void draw(){System.out.println("drawing rectangle");}
}

class Test{
public static void main(String args[]){
Shape S=new Circle();
S.draw();

}}

multiple inheritance by interface :

interface Shape{
void draw();
}

interface Color{
String getColor();
}


class Rectangle implements Shape,Color{
public void draw(){System.out.println("drawing rectangle");}
public String getColor(){return("red");}
}

class Test{
public static void main(String args[]){
Rectangle s=new Rectangle();
s.draw();
System.out.println(s.getColor());
}}

                                            JAVA TUTORIALS HOMEPAGE

abstraction in java :: futureX

Abstraction is a process of hiding the implementation details and showing only functionality to the user.Abstraction lets you focus on what the object does instead of how it does it.


Ways to achieve Abstraction:
Abstract class (0 to 100%)
Interface (100%)

Abstract class:
A class that is declared as abstract is known as abstract class.It needs to be extended and its method implemented.It cannot be instantiated.


           abstract class class_name{}

Abstract method:
A method that is declared as abstract and does not have implementation is known as abstract method.


          abstract return_type method_name();    //no braces{}

Example:

abstract class Shape{
abstract void draw();
}

class Rectangle extends Shape{
void draw(){System.out.println("drawing rectangle");}
}

class Circle extends Shape{
void draw(){System.out.println("drawing circle");}
}

class Test{
public static void main(String args[]){
Shape s=new Circle();
s.draw();
}
}


Note: An abstract class can have data member,abstract method,method body,constructor and even main() method.

Rule: If there is any abstract method in a class, that class must be abstract.

//Shape is not abstract and does not override abstract method //draw() in shape

class Shape{
abstract void draw();
}


                   JAVA TUTORIALS HOMEPAGE





What is HTML?

indroduction to HTML :: futureX
  • HTML is a language for describing web pages.
  • HTML stands for Hyper Text Markup Language
  • HTML is a markup language
  • A markup language is a set of markup tags
  • The tags describes document content
  • HTML documents contain HTML tags and plain text
  • HTML documents are also called web pages


HTML Tags


  • HTML markup tags are usually called HTML tags
  • HTML tags are keywords (tag names) surrounded by angle brackets like <html>
  • HTML tags normally come in pairs like <b> and </b>
  • The first tag in a pair is the start tag, the second tag is the end tag
  • The end tag is written like the start tag, with a forward slash before the tag name
  • Start and end tags are also called opening tags and closing tags


                                      <tagname>content</tagname>


HTML Elements

"HTML tags" and "HTML elements" are often used to describe the same thing.
But strictly speaking, an HTML element is everything between the start tag and the end tag, including the tags.
               <p>This is a paragraph.</p>


Web Browsers

The purpose of a web browser (such as Google Chrome, Internet Explorer, Firefox, Safari) is to read HTML documents and display them as web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page.

HTML Versions

Since the early days of the web, there have been many versions of HTML:
Version                        Year
HTML                          1991
HTML+                        1993
HTML 2.0                    1995
HTML 3.2                    1997
HTML 4.01                  1999
XHTML 1.0                  2000
HTML5                        2012
XHTML5                      2013

The <!DOCTYPE> Declaration

The <!DOCTYPE> declaration helps the browser to display a web page correctly.
There are many different documents on the web, and a browser can only display an HTML page 100% correctly if it knows the HTML type and version used.

Common Declarations

HTML5

<!DOCTYPE html>

HTML 4.01

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

XHTML 1.0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

For a complete list of document type declarations, go to our DOCTYPE Reference.


« HTML Home                                                                                                                                                  Next Chapter »


Copyright © 2013 futureX | Blogger Template by Clairvo