Thursday, March 23, 2017

Comments in Java

Comments:

Use // text when you want to comment a single line of code. 
Use /* text */ when you want to comment multiple lines of code. 
Use /** documentation */ when you would want to add some info about the program that can be used for automatic generation of program documentation.

History of Java

History of Java:

 
Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.


Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. As of 2016, Java is one of the most popular programming languages in use, particularly for client-server web applications, with a reported 9 million developers. 

1) James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. The small team of sun engineers called Green Team.
2) Originally designed for small, embedded systems in electronic appliances like set-top boxes.
3) Firstly, it was called "Greentalk" by James Gosling and file extension was .gt.
4) After that, it was called Oak(Programming Language) and was developed as a part of the Green project.


<---Back to JAVA BASICS            Next Java buzzwords---> 

JAVA Buzzwords

Java Features or Java Buzzwords:



Following are the features or buzzwords of Java language which made it popular:
1.Simple
2.Secure
3.Portable
4.Object-Oriented
5.Robust
6.Multithreaded
7.Architecture neutral
8.Interpreted
9.High Performance
10.Distributed
11.Dynamic

Simple:
•Java easy to learn
•It is easy to write programs using Java
•Expressiveness is more in Java.
•Most of the complex or confusing features in C++ are removed in Java like pointers etc..

Secure:
•Java provides data security through encapsulation.
•Also we can write applets in Java which provides security.
•An applet is a small program which can be downloaded from one computer to another automatically.
•There is no need to worry about applets accessing the system resources which may compromise security.
•Applets are run within the JVM which protects from unauthorized or illegal access to system resources.

Portable:
•Applications written using Java are portable in the sense that they can be executed on any kind of computer containing any CPU or any operating system.
•When an application written in Java is compiled, it generates an intermediate code file called as “bytecode”.
•Bytecode helps Java to achieve portability.
•This bytecode can be taken to any computer and executed directly.

Object - Oriented:
•Java follows object oriented model.
•So, it supports all the features of object oriented model like:
Encapsulation
Inheritance
Polymorphism
Abstraction

Robust:
•A program or an application is said to be robust(reliable) when it is able to give some response in any kind of context.
•Java’s features help to make the programs robust. Some of those features are:
1. Type checking
2. Exception handling

Multithreaded:
•Java supports multithreading which is not supported by C and C++.
•A thread is a light weight process.
•Multithreading increases CPU efficiency.
•A program can be divided into several threads and each thread can be executed concurrently or in parallel with the other threads.
•Real world example for multithreading is computer. While we are listening to music, at the same time we can write in a word document or play a game.

Architecture - Neutral:
•Bytecode helps Java to achieve portability.
•Bytecode can be executed on computers having any kind of operating system or any kind of CPU.
•Since Java applications can run on any kind of CPU, Java is architecture – neutral.

Interpreted and High Performance:
•In Java 1.0 version there is an interpreter for executing the bytecode. As interpreter is quite slow when compared to a compiler, java programs used to execute slowly.
•After Java 1.0 version the interpreter was replaced with JIT(Just-In-Time) compiler.
•JIT compiler uses Sun Microsystem’s Hot Spot technology.
•JIT compiler converts the byte code into machine code piece by piece and caches them for future use.
•This enhances the program performance means it executes rapidly.

Distributed:
•Java supports distributed computation using Remote Method Invocation (RMI) concept.
•The server and client(s) can communicate with another and the computations can be divided among several computers which makes the programs to execute rapidly.
•In distributed systems, resources are shared.

Dynamic:
•The Java Virtual Machine(JVM) maintains a lot of runtime information about the program and the objects in the program.
•Libraries are dynamically linked during runtime.
•So, even if you make dynamic changes to pieces of code, the program is not effected.

<---Back to History of Java         Next Comments---> 

Friday, March 17, 2017

Cascading style sheets In HTML



Cascading style sheets
   A style is a set of formatting instructions that can be applied to a piece of text.  There are three mechanisms by which we can apply styles to our HTML documents.
1. Inline style sheets
2.Internal style sheets
3.External style sheets

Inline style sheets:
   In the inline style the style is defined within the body of the HTML document itself.  For example
<html>
<head>
<title>Inline style sheets</title>
</head>
<body>
<p style=”margin-left:10%;border:ridge;background:0000ff”>
Welcome To CSS
</p>
</body>
</html>


Internal style sheets:
   A style sheet can be defined in the header section with the <style> tag corresponding ending </style> tag.  This way of defining style sheets is called an internal style sheets.

<html>
<head>
<title>internal style sheets</title>
<style>
<!---h1
{margin:10%;
Align:left
Font face: Times New Roman
}
--->
</head>
</style>
<body>
<h2>OmgMca.blogspot.in</h2>
</body>
</html>

In the above example h1 tag is re defined.  The font face is name of the font that is  Times New Roman, margin for the text is 10% and the alignment is left placed around it.

External Style sheets:
   In this case of external style it is stored in a separate file.  This style sheet can be linked to no.of HTML documents

Body{font:14pt “Arial”;color:black:background:orange}
H1{font: 12pt “Times Roman” bold}
P{font:12pt “Times Roman”}
H4{font:26pt “Times New Roman” Italics}
A(text decorator: blinking; color: green)

   This style sheets can be linked by the link tag of the header section as follows

<link rel=styleshhet href=”ex.css” type=”test/css”>

The attribute rel=stylesheet informs is that this link tag is for linking a style sheet to the document.
   The href=”ex.css” informs that ex.css is the file name of the style sheet. Tyle/css informs as that the style sheet type is text/css


Properties of style sheets:
       A number of properties for available formatting text using style sheet.  These are as follows

Fonts:
Fonts are identified by giving the name of a specified font.  This is called font family.

H{
Font family=”Arial”}
   The font family properly specifies the name of the font that should be displayed.  In this case we use Arial font.

Font style:
   The style property defines that the font to be displayed in one of three ways that are normal, italic, bold.

Example:

P{
Font_style=”italic”;}
Font weight:{normal/bold/bolder/lighter/100/200}

   The first four option are relative while the numbered values is the absolute weights and not all fonts not support to all possible weights and should be careful while using the absolute weights.
Font size: (large, 10, 12, 14----)
   The absolute size of font is small, medium, and large.

Example:

H1{
Font_size=”12pt” font_style=”italic”}

Text decoration:
  Any piece of text can be decorated the underline can be removed for hyperlinks by using the following code

A:link, A:visited, A:actice
{
Text.decoration.overline;
}

Borders:
   Borders colors and styles can also be applied to the border of their box using the following syntax.

Border-color=”pink”;
Border-style=”doubled, dashed, dotted;”

   IN the above example the color pink is specified to margins that is top and bottom, the border style is dotted to margin.



<--Back to HTML Common tag 

Monday, March 13, 2017

Frames in HTML



Frames:


   Frames are a one of the html feature.  Frames are introduced by Netscape communication it’s allows to divided into a browser window in several parts.  Each part called container.  Frames have the following characteristics.
-Each frame is given a name and each frame will be targeted by an html document.
-Each frame work it’s self.
    A group of frames in a single browser window is called a frameset.
A set of frames is defined by using the <framset> (frame set tag). Frame set has two attributes.
1. Rows frame
2. Columns frame

Rows frame:
   The rows attribute of <frameset> tag defines horizontal frames.

Example:  <frameset rows=”40%,60%”>

Columns frame: (cols)
   The cols attribute of <frameset> tag defines vertical frames.

Example: <frameset cols=”20%,80%”>

    The size of each frame in rows frame or columns frame can be defined there values by pixels or percentages


Using pixels:
 <frameset cols=”200,150”>

Here the first frame contains 200 pixels and second frame contains 150 pixels.

Using percentages
 <frameset cols=”20%,80%”>

Here the first frame contains 20 percent of size in that webpage and second frame contains 80 percent on that web page.

Frame tag (<frame>):

The frame set has the following attributes
1. Source
2. Name
3. Margin
4. Scrolling bar

Source:
   The source attribute gives the location html document.

Name:
   A frame is given a name to identify which specified the target of html document.  The frame begins with an alphabetic letter.

Margin:
By using this attribute we can give the margin width and margin height to the frame border and its contents.  The values are given in pixels.

Example:
 <frame name=”first” src=”fruits.html” marginwidth=”5” marginheight=”5”>

Scrolling bar:
   The scrolling attribute is used to describe whether the frame should have scroll bar or not.

Example:
<frame name=”first” src=”birds.html” scrolling=”yes”>

Nested frames:
   It is possible to devoid a frame into again and again.

Example:
<frameset cols=”70%,30%”>
<frameset rows=”80%,20%”>

-----------------------------------------------------------------------------------------------------------------

Program 1: we are saving this file name as fruits.html
<html>
<head><title>Fruits</title>
</head>
<body>
<ol>
<li>Apple</li>
<li>Mango</li>
<li>Banana</li>
</ol>
</body>
</html>


Program 2: we are saving this file name as birds.html
<html>
<head>
<title>Birds</title>
</head>
<body>
<ul>
<li>Peacock</li>
<li>Pegion</li>
<li>Parrot</li>
</ul>
</body>
</html>


Program for  Frames:

<html>
<head>
<title>Frameset</title>
</head>
<frameset cols="20%,70%">
   <frame src="fruits.html" name="First">
   <frame src="birds.html" name="second">
</frameset>
</html>

Forms in HTML



Forms:

   Form is a mechanism that allows typing information in to fields on a browser screen and submits that information to a web server.  Using interactive web pages can be created so a form fill out and can be submitted and can be achieved required results.  Form can be using for gathering information about a user, conducting survey, registration etc.

Form tag (<form>):

   The begging and ending tags of the form creation are <form>, </form>.  All of the values assigned to items between this tags.

Form input tags:
   Form input tag is used to generate a various types of input tags such as
1. Text boxes
2. Check boxes
3. Radio buttons
4. Action button
5. File upload box

Text Boxes:
   A rectangular shaped field in which a user can enter test is called a text box.  A text box is produced using the input tag and specifying the appropriate attribute.
Example:
<input type=”text” name=”name” value=”10”>
Here
The value assigned to the type attribute is ‘text’.  This is used for producing a text box.
   The name attribute specifies name of the parameter that can be assigned the value that the user enter to field.
   The value attribute used to provide an initial value inside the control
We can also use “size” attribute it will allows to specify the width of the text input control in terms of characters and also we will use “maxlength” it allows to specify the maximum number of characters a user can enter into the text box.


Program:
<html>
<head>
<title>text box</title>
</head>
<body>
<form>
NAME<input type=”text” name=”name”> <br>
DOB<input type=”text” name=”age”>
</form>
</body>
</html>

Output:

Check box:

   A check box is represented by a icon that the user can select or deselect by clicking on it.

Example:
Mathematics<input type=”checkbox” name=”subjects”>
Statistics<input type=”checkbox” name=”subjects”>
Computers<input type=”checkbox” name=”subjects”>

Program:

<html>
<head>
<title>check box</title>
</head>
<body>
<form>
Favorite subject <br>
<input type="checkbox" name="maths" > Maths<br>
<input type="checkbox" name="physics"> Physics<br>
<input type="checkbox" name="computers"> computers
</form>
</body>
</html>

Output:

Radio Buttons:
   The radio buttons were designed such that only one button would be depressed at a given time.  Pushing in one button forced the currently selected button to deselected.

Example:
OBC<input type=”radio” name=”cast”>
OC<input type=”radio” name=”cast”>
SC<input type=”radio” name=”cast”>

Program;

<html>
<head>
<title>Radio Box</title>
</head>
<body>
<form>
<input type="radio" name="cast"> OBC
<input type="radio" name="cast"> OC
<input type="radio" name="cast"> SC
</form>
</body>
</html>

Output:



Select button:
  A select box, also called drop down box. The starting and ending tags are <select>, </select>. On this tags by using option tag (<option>) we can give the options in the form of drop down list.

Example:

<select>
<option>male</option>
<option>female</option>
<option>others</option>
</select>


Program:

<html>
<head>
<title>Select Box</title>
</head>
<body>
<form>
<select>
<option value="Male" selected>Male</option>
<option value="female">female</option>
<option value="others">others</option>
</select>
</form>
</body>
</html>

Ootput:

Password:
    By using this we can generate password in a text box.

Example:
<input type=”password” name=”name”>

Program:

<html>
<head>
<title>Password</title>
</head>
<body>
<form >
User ID :<input type="text" name="userid"><br>
Password:<input type="password" name="password">
</form>
</body>
</html>

Output:


Action button:
   There are two types of action buttons they are:
 1.Submit
2. Reset

The user click on submit button the value that have entered into the form are send to the web server.  The reset button is to allow the user to clear all the input data.

<input type=”submit” values=”submit”>
<input type=”reset” values=”reset”>

Program:

<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
first name<input type="text" name="name"><br>
last name<input type="text" name="name"><br>
middle name<input type="text" name="name"><br><br>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset"  value="Reset">
</form>
</body>
</html>

Output:

File upload Box:
   If you want to allow a user to upload a file to your web site, you will need to use a file upload box.

<input type=”file” name=”upload” accept=”image”>


Program:

<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<input type="file" name="fileupload" accept="image/*">
</form>
</body>
</html>

Output:

Saturday, March 11, 2017

Images in HTML



By using image tag (<image>) we can provide image to the web page.  In image tag we have the following attributes.
1. Source
2. Align
3. Width
4. Height
5. Border
6. Horizontal space
7. Vertical space

Source (<src>):
   In source attribute we give the image location. The image formats are JPEG, PNG or GIF.
alt attribute is a mandatory attribute. If image cannot be displayed then specified text will be displayed.  
Example:
<image src=” D:\fly.jpg” alt=”fly”>

Align:
   In align attribute we give the position of an image.  The position are left, right, top, bottom and center.
Example:
<image src=”fly.png” alt=”fly” align=”center”>

Width:
   By using width attribute we can mention the width of an image.

Height:
   By using height attribute we can provide the height of an image.
Example:
<image src=”fly.png” alt=”fly” width=”200” height=”120”>

Border:
Image will have a border around it, you can specify border thickness in terms of pixels using border attribute.
Example:
<image src=”fly.png” alt=”fly” border=”5”>

Horizontal space (hspace):
   By using horizontal space we can provide horizontal space to an image.

Vertical space (vspace):
   By using vertical space we can provide vertical space to an image.
Example:
<image src=”sunset.jpg” alt=”sun set” vspace=”50” hspace=”30”>

Example program:
<html>
<head>
<title>Set Image Alignment</title>
</head>
<body>
<p>Setting image Alignment</p>
<img src="Pawanism.jpg" alt=" pavan kalyan" border="3" align="right" width="200" height="200" vspace="100" hspace="200">
</body>
</html>

Output:

 

<--Back to HTML Common tag