Saturday, 16 June 2018

Chaudhari Karan

HTML – Images

By     No comments:

HTML – Images

Hello friends, In this lecture, we will discuss HTML – Images.
HTML – Images


Images are used for design beautify web page. This lecture will take few simple steps to use images in web pages.

Insert Image

In HTML tag are used for insert any image in web page. Here is the simple syntax to use tag.



The image tag has no closing tag. It is contain only attributes-list.

Example

In this example HTML file and image file in the same directory –

HTML Insert Image

Output
HTML Insert Image


In HTML image use PNG, JPEG or GIF image file, but make sure to specify correct image file name in src attribute. The image name is always case sensitive.

The alt attribute is the mandatory attribute, it specifies an alternate text for the image if the image not displayed.

Set Image Location

If all the images in a separate directory. So HTML file in home directory and create the subdirectory images inside the home directory where keep the image.

Example

Assume our image location is "image/alwaysspot.png".

HTML Set Image Location

Set Image Width/Height

We can set image width and height based on our requirement. For set image width and height using the attributes. Attributes can specify width and height of the image in pixels or percentage of its actual size.

Example
HTML Set Image Width/Height


Output
HTML Set Image Width/Height

Set Image Border

The image has a border around it by default, it can specify thickness in pixels using border attribute. The thickness of 0 which means no border around the image.

Example
HTML Set Image Border

Output
HTML Set Image Border

Set Image Alignment

The image is aligned at the left side of the page by default but can use align attribute to set in the right or center.

Example
HTML Set Image Alignment
Output

HTML Set Image Alignment



Read More

Thursday, 14 June 2018

Chaudhari Karan

HTML – Comments

By     No comments:

HTML – Comments

Hello friends, In this lecture, we will discuss HTML – Comments.
HTML – Comments

Any piece of code is placed between tags is known as comments. The comment is ignored by a web browser. Add comments into  HTML code, especially in complex documents. It is indicated sections of the document, and other notes to looking at the code. Comments help to understand code and increases code readability.

HTML are used tags for comments. So, any content in this tag   is treated as comment and it is ignored by the web browser.

Example:
HTML – Comments

Output:
HTML – Comments

Valid vs Invalid Comments

In comments, you cannot put inside another comment. It is known as invalid comments.

Second, you cannot use spaces in start comments string like < !--.. -->. This is also invalid comments. So make sure for valid comment does not use spaces in the start-of comment string.

Example

Here, the valid comment example and it will be wiped off by the web browser.

HTML Valid vs Invalid Comments


Here, the invalid comment example and it will be displayed by the web browser. There is a space between the left angle bracket and the exclamation mark.

HTML Valid vs Invalid Comments

Multiline Comments

In above examples, we have seen single line comments, but HTML also supports multi-line comments.

Multiple lines comment also beginning with a tag . In this tag place multiline of comments as shown in the example.

Example:
HTML Multiline Comments

Conditional Comments

Conditional comments only support by Internet Explorer IE on Windows. It is ignored by other web browsers. You can give conditional instructions to different versions of IE.

Example:
HTML Conditional Comments



Using Comment Tag

Internet Explorer browsers support tag to comment the part of HTML code.

Note − The tag is not used in HTML5.

Example:
HTML Using Comment Tag

Commenting Script Code

Through JavaScript and HTML code is recommended to put that script code inside the HTML comments.

Example:

HTML Commenting Script Code
Output:
HTML Commenting Script Code

Commenting Style Sheets

Cascading Style Sheet CSS used in HTML comments as shown in the example.

Example:
HTML Commenting Style Sheets


Output:
HTML Commenting Style Sheets

Read More

Monday, 11 June 2018

Chaudhari Karan

HTML – Meta Tags

By     No comments:

HTML – Meta Tags

Hello friends, In this lecture, we will discuss HTML Meta Tags.

HTML – Meta Tags

HTML metadata - additional important information of the document in a variety of ways. The META elements are used to include name or value pairs describing properties of the HTML document, like the author, expiry date, a list of keywords, document author etc.

The tag is provide the additional information. It is an empty element and it does not have the closing tag and it carries information with its attributes.

One or more meta tags in the document are based on the information what you keep in your document, meta tags cannot impact the physical appearance of the document.

Adding Meta Tags to Your Documents


Add metadata to web pages using tags inside the header of the document.  It is represented by and tags. Here are meta tag attributes in addition to core attributes −

Attributes
                                                               Description
Name
It is used for giving the name for the property. For Example include, keywords, description, author, revised, generator etc.
Content
It specifies the property's value.
Scheme
The scheme is specifies to interpret the property's value as declared in the content attributes.
http-equiv
It is used for http response message headers. For example, it is used for refresh the page or to set the cookie. Values include content-type, expires, refresh and set-cookie.

Specifying Keywords


The tag to specify the important keywords related to the document and these keywords are used by the search engines while indexing webpage for searching purpose.

Example:
In this example, adding HTML, Meta Tags, Metadata as important keywords.

HTML Specifying Keywords

Output:
HTML Specifying Keywords




Document Description


The tag give the short description of the document. It is used by search engines while indexing webpage for searching.

Example:
HTML Document Description

Output:
HTML Document Description

Document Revision Date


The tag gives information when last time the document was updated. It is used by various web browsers while refreshing webpage.

Example:
HTML Document Revision Date

Document Refreshing


The tag is used to specify the duration after which web page will keep refreshing automatically.

Example:
If web page keeps refreshing after every 5 seconds then use the following syntax.

HTML Document Refreshing


Page Redirection


The tag to redirect webpage to another webpage. It specifies a duration if redirect the page after a certain number of seconds.

Example

In this example redirecting current page to another page after 5 seconds. If you want to redirect page immediately then not specify the content attribute.

HTML Page Redirection

Setting Cookies


Cookies are data which is stored in small text files on the computer. It is exchanged between the web browser and web server to track information based on web application need.

The tag to store cookies on the client side, this information used by the Web Server to track a site visitor.

Example

In this example redirecting current page to another page after 5 seconds. If redirect page immediately then do not specify the content attribute.

HTML Setting Cookies

Setting Author Name


For set the author name in a web page using meta tag.

Example:
HTML Setting Author Name

Specify Character Set


This tag to specify character set used with the webpage.

Example:

In default web, servers and web browsers use ISO-8859-1 Latin1 encoding to process Web pages. In this example UTF-8 encoding use.
HTML Specify Character Set


Set Big5 encoding to serve the static page with traditional Chinese characters.

HTML Specify Character Set

Read More

Saturday, 9 June 2018

Chaudhari Karan

Java – Modifier Types

By     No comments:

Java – Modifier Types

Hello friends, In this lecture, we will discuss Java Modifier types.
Java – Modifier Types


There are two types of Modifier.
  • Java Access Modifiers
  • Non Access Modifiers

Java Access Modifiers

Java has a number of access modifiers. That modifier set access levels for classes, variables, methods, and constructors. Here are four access levels:
  • It is visible to the package, the default. No modifiers are needed.
  • Visible to the private class only.
  • Visible to the public world.
  • Visible to the package and all protected subclasses.

Default Access Modifier - No Keyword

It means do not explicitly declare an access modifier for the class, field, method, etc.

A variable and method declared without access modifier. It is available to other class in the same package. The fields in the interface are implicitly public static final and the methods in the interface are by default public.

Example:
Variable and method declared without any access modifier.
Default Access Modifier - No Keyword


Private Access Modifier - Private

Methods, variables, and constructors are declared as private. It can access the declared class itself.

Private access modifier is the restrictive access level modifier.

Class and interfaces are not private.

Variables are declared as private. It can access outside the class if public methods are present in the class.

The private modifier is the object encapsulates itself and hides data from the outside world.

Example:
Java Private Access Modifier - Private


Here, the format variable is private in Example class, but there is no way for other classes to retrieve or set its value directly.

This variable available is the outside world, here is defined two public methods: getFormat(), which returns the value of format, and setFormat(String format), which sets its value.

Public Access Modifier – Public

Any class, method, constructor, interface, etc. declared as public. It can be accessed from other classes. But fields, methods, and blocks declared inside the public class which accessed from any class.

If the public class is trying to access in the different package.

Because of class inheritance method, all public methods and variables of the class are inherited by subclasses.

Example:

Java Public Access Modifier – Public


The main() method of an application is public. Otherwise, it not called by a Java interpreter to run the class.

Protected Access Modifier - Protected

Variables, methods, and constructors,  declared as protected in the superclass. It accessed by the subclasses in other package or class with the package of the protected members' class.

The protected access modifier is not applied to the class and interfaces. Methods, fields are declared as protected, but methods and fields in the interface are not declared protected.

Protected access the subclass to use the method or variable while preventing the nonrelated class.

Example:
Java Protected Access Modifier - Protected

Access Control and Inheritance

Here is rules for inherited methods are enforced:
  • Methods are declared public in the superclass and must be public in all subclasses. 
  • Methods are declared protected in the superclass and must be protected or public in subclasses; it cannot be private. 
  • Methods are declared private are not inherited.

Java Non-Access Modifiers

Java has a number of non-access modifiers to achieve other functionalities.
  • The static modifier is used for creating variables and class methods. 
  • The final modifier is used for finalizing the implementations of methods, classes, and variables. 
  • The abstract modifier is used for creating abstract classes and methods. 
  • The synchronized and volatile modifiers are used for threads.

The Static Modifier

Static Variables

The static variable is used as the static keyword for creating variables. It exists independently of any instances created for the class. The static variable exists regardless of the number of instances of the class.

Static variables are also called as class variables. But,  local variables are not declared as static.



Static Methods

The static keyword is used to creating static methods. It will independently of any instances created for the class.

Static methods do not use instance variables of an object of the class. Static methods take all the data from parameters and compute that parameter, without reference to variables.

Class variables and methods are accessed by the class name.

Example:
Java Static Methods

Output:
Java Static Methods

The Final Modifier

Final Variables

A final variable is explicitly initialized only once. The reference variable declared as final. It cannot reassign to the different object.

The data with the object it can be changed. The state of the object changed but cannot the reference.
The final modifier with variables is used with static to make as the constant the class variable.

Example:
Java Final Variables

Final Methods

 A final method cannot override by any other subclasses.

The main intention of the final method is that the content of the method not be changed by an outsider.

Example:
Java Final Methods

Final Classes

The main purpose of the final class is declared as final to prevent the class from subclassing. If the class is marked as final then the class cannot inherit any feature from the final class.

Example:
Java Final Classes

The Abstract Modifier

Abstract Class

An abstract class never instantiated. If any class is declared as abstract then the class to be extended.
A class cannot be abstract and final. If the class contains abstract methods then the class declared as abstract. Otherwise, a compile give the error.

An abstract class contains both abstract methods and normal methods.

Example:
Java Abstract Class


Abstract Methods

An abstract method is a method declared without any implementation. Abstract methods cannot be final or strict.

If any class extends an abstract class it implements all the abstract methods of the superclass, unless the subclass an abstract class.

If any class contains one or more abstract methods, and the class declared as abstract. An abstract class does not need to contain abstract methods.

An abstract method ends with the semicolon.

Example: public abstract sample();

Java Abstract Methods


The Synchronized Modifier

The synchronized keyword is used to indicate a method can access by only one thread. The synchronized modifier applied with four access level modifiers.

Example:
Java Synchronized Modifier

The Transient Modifier

An instance variable is transient to indicate the JVM to skip the particular variable when it serializing the object containing.

The modifier is included in the statement which creates the variable, preceding the class or data type of the variable.   

Example:
Java Transient Modifier

The Volatile Modifier

The volatile modifier is used to the JVM, that a thread accessing the variable.

Volatile only applied to the instance variables, which are of type object or private. A volatile object reference is null.

Example:
Java Volatile Modifier


run() method is called in one thread, and stop() method is called from another thread.
To use a modifier, need to include its volatile keyword in the definition of a class, method, or variable.
Java Volatile Modifier

Access Control Modifiers

Java has the number of access modifiers to access levels for classes, variables, methods, and constructors. Here is four access level:
  • It is visible to the package, the default. No modifiers are needed.
  • Visible to the private class only.
  • Visible to the public.
  • Visible to the package and all protected subclasses.


Read More