Friday, December 26, 2014

Object and Class in Java

Object in java:

The objects are the physically existing entities in java which are used for specific purpose.

Every object has certain state and behaviour, and will perform specific action.
An object has three characteristics:
  • State: represents data of an object.
  • Behaviour: represents the functionality of an object such as deposit, withdraw etc.
  • Identity: Object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. But,it is used internally by the JVM to identify each object uniquely.

Object is an instance of a class. Class is a template or blueprint from which objects are created.

Class in java

A class is a core component of  java because without a class we cannot write a single statement in java.A class is a collection of objects that have the same properties. Class contains the fallowing members

  • data member
  • method
  • constructor
  • block
syntax
class <class name>{
//blocks
//constructors
//variables
//methods
}

 Example of Object and Class

In this example, we have created a Student class that have two data members id and name. We are creating the object of the Student class by new keyword and printing the objects value.
class Employee{ 
int  eno;  // instance variable declaration
String  ename; // instance variable declaration
public static void main(String ar[]){   // main method
Employee e=new Enployee();    // creating object to employee class
System.out.println(e.eno); // displaying employee number  of  employee class
System.out.println(e.ename);  // displaying employee name  of employee class
}
}
Out-put:
0 
null

Java Naming conventions

The naming conventions are a set of rules that the developers have to fallow while writing the code. These rules decide what to name your identifiers such as packages, interfaces, classes, variables, constants and methods. While giving the names to these identifiers we should fallow these conventions given by sun Microsystems.
The fallowing are the areas where we have to fallow the naming conventions:
Class name: A class name should be meaningful and always it should start with uppercase letter. If the class name is the combination of two or more words then every word first letter should be in uppercase and we should see that there should not be any spaces or special characters except underscore in between the class name.
e.g. String, Color, Button, System, Thread etc.
Interface name: The interface names also fallow the same naming conventions as that of class. 
 e.g. Runnable, Remote, ActionListener etc.
Package name: unlike class name or interface name the package name always should start with lowercase letters.
e.g. java, lang, sql, util etc.
method name: A method name should start with lowercase and if the method name is a combination of two or more words then the second word onwards every word  first letter should be in uppercase.
e.g. actionPerformed(), main(), print(), println() etc.
variable name: A variable name should start with lowercase in all the cases.
e.g. firstName, orderNumber etc. 
constants name:  The constants should be declared in uppercase. 
e.g. RED, YELLOW, MAX_PRIORITY etc.

Object oriented programming language

An object is considered as a real world entity. Object is an instance of a class. Any programming language in the world which satisfies the object oriented features is considered as a object oriented programming language i.e every program developed using the concerned programming language must fallow the basic concepts that are stated in Oops. The fallowing are the basic concepts of oops:
  • Class
  • Object
  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation

Class

A class is a logical one which cannot be visible. A class contains variables and methods. A class  is a model for creating objects.

Object

An entity which has a specific structure and behaviour is called as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical.

Inheritance

  The process of deriving a new class from the existing class is called inheritance. In this context the new class is called derived class and the existing class is called as base class. The derived class will acquire all the properties and behaviours of the base class. Using inheritance we can achieve code reusability. It is also used to achieve runtime polymorphism.

 Polymorphism
 An Object which exhibits multiple behaviours is called as polymorphism. Polymorphism is derived from the Greek word where poly means many morphic means forms. Using method overloading and method overriding we can achieve polymorphism.
Abstraction:
Hiding the internal details of a programme but displaying the functionality is called  abstraction.
Encapsulation:
The process of binding the member variables with the methods of a class is called encapsulation. Java beans is the best example for encapsulation.

Control Statements in Java

We have 3 types of Control Statements in Java. They are,
-- Conditional Control Statements
-- Iterative Control Statements
-- Transfer/Jump Control Statements
Control Statements in java
1) Conditional control statements:
Conditional Statements will work based on the conditions. We have different types of Conditional Statements. They are,
i) if : If the condition is true then the control will execute the block of statements otherwise the control will not enter into if block
Syntax:
if(condition)
{
statement1;
statement2;
----------
}
ii) if-else : If the condition is true then the control will execute the if block otherwise the control will execute else block
Syntax:
if(condition)
{
statement1;
statement2;
}
else{
statement3;
statement4;
}
2) Iterative Control Statements:
Iterative control statements are used to execute the group of statements repeatatively based on a condition.
ex:
i) while
ii) do-while
iii) for
3) Transfer/Jump Control Statements:
whenever these statements are encountered then the control will be transfered from one place to another.
ex:
i) break
ii) continue
iii) return

Tuesday, December 23, 2014

Variables in Java

Variable in java can be defined as a name for a memory location which can hold the data.
Variable declartion:
syntax:
<modifier> <Data Type> <var-Name>;
or
<modifier> <Data Type> <var-Name>= value;
There are 3 types of variables are there in java. They are,
1)Local Variables
2)Instance Variables
3)Static Variables
1) Local Variable:
a variable which is declared inside a method is called as Local variable.
ex:
void m1(){
int a=10; // local varible declaration
int b=20; // local varible declaration
}
Note:
Local variables must and should be initialized before using. Otherwise we will get Compile time error.
2) Instance Variable:
a variable which is declared inside a class but not inside any method, without static keyword is called as Instance variable.
ex:
class MyProgram{
int a=10; // Instance varible declaration
int b; // Instance varible declaration
}
Note:
If we not initialize Instance variables then it will be initialized by default values of that data type.
3) Static Variable:
a variable which is declared inside a class but not inside any method, with static keyword is called as Static variable.
ex:
class MyProgram{
static int a=10; // local varible declaration
static int b; // local varible declaration
}
Note:
If we not initialize Static variables then it will be initialized by default values of that data type.

Control Statements in Java
We have 3 types of Control Statements in Java. They are,
-- Conditional Control Statements
-- Iterative Control Statements
-- Transfer/Jump Control Statements
Control Statements in java
1) Conditional control statements:
Conditional Statements will work based on the conditions. We have different types of Conditional Statements. They are,
i) if : If the condition is true then the control will execute the block of statements otherwise the control will not enter into if block
Syntax:
if(condition)
{
statement1;
statement2;
----------
}
ii) if-else : If the condition is true then the control will execute the if block otherwise the control will execute else block
Syntax:
if(condition)
{
statement1;
statement2;
}
else{
statement3;
statement4;
}
2) Iterative Control Statements:
Iterative control statements are used to execute the group of statements repeatatively based on a condition.
ex:
i) while
ii) do-while
iii) for
3) Transfer/Jump Control Statements:
whenever these statements are encountered then the control will be transfered from one place to another.
ex:
i) break
ii) continue
iii) return

Data Types in Java

DataType is used to represent the data which we store in the memory in the form of variables.
In Java we have 2 major types of datatypes.
-- Primitive Datatypes
-- Non-Primitive Datatypes
Data Types
1) Primitive Data Types
-- Numeric
----------Integer
      -----------byte
      -----------short
      -----------int
      -----------long
----------Decimal
      -----------float
      -----------double
--Non-Numeric
      -----------char
      -----------boolean
2) Non-Primitive Data Types
--Derived Data Type
      -----------String
      -----------Array, etc.
--User-Defined Data Type
      -----------class
      -----------interface
      -----------enum, etc.

Basic java Programm

Let us consider a java program with file name MyFirst.java
Creating Hello world program
public class MyFirst{
public static void main(String args[]){
System.out.println("Hello World..!");
}
}
to compile:
javac MyFirst.java
to execute:
java MyFirst

Output:
Hello World..!

Monday, December 22, 2014

Installation of Java

Installation of Java
Java Software Developement Kit(JDK) is a software created by SUN Microsystems to create or modify the java programs/applications.
We need to install JDk in our machines first. for software click here
After installing JDK we need to set the path. We can set the path in 2 ways.
1) Temparory path setting
We can set path temporarily from command prompt
C:\ set path= C:\Program Files\Java\jdk1.6_23\bin
2) Perminent Path Setting
MyComputer properties -> advanced system setting -> environmental variables -> user variables -> new -> 
variable name : path 
variable value : C:\Program Files\Java\jdk1.6_23\bin -> ok -> ok -> ok

Basic java Programm

Let us consider a java program with file name MyFirst.java
Creating Hello world program
public class MyFirst{
public static void main(String args[]){
System.out.println("Hello World..!");
}
}
to compile:
javac MyFirst.java
to execute:
java MyFirst

Output:
Hello World..!

Features of Java

Features of Java
Java having a huge no of features. some of them are,
1) simple language
2) Object oriented programming language
3) Platform Independent Language
4) Portable language
5) Architechture nutral
6) Simply mulithreaded language
7) Robust
8) Dynamic
9) Compiler and Interpretter based language
10) Distributed
11) Secure
12) High Performence

Sunday, December 21, 2014

How to Install PHP

To develop and run php website in your system ,we have different types of components.Php works in any operating system.

For UI(user interface)---Adobe Dreamviewer
for webserver-----Wamp / xamp/apache server
WAMP Server download link : : Wamp Server
when you are installing the wamp server automatically mysql server will beinstalled in your system.

After installing the wamp server automatically path is created.....in c:/wamp/www

Features of PHP

  1. Easy development of web applications
  2. Automatic memory management
  3. Strong XML support
  4. Ease of deployment and configuration
  5. Security

Introduction Of PHP(Personal Home Page)

PHP means PHP(Personal Home Page) Hypertext Pre-processor..Php is open source code.It is a server-side scripting language, and is powerful tool making the dynamic web pages.This server-sidescripts are special commands you must place in Web pages. PHP is html embedded script language,it is the common syntax like c,java..It is vary easy to design the web page and to reduce the time to create the large web pages.It is widely-used as an alternate to ASP.PHP is interacts with number of databases like mysql, sqlserver, oracle.It is simple,efficience,flexible to learn.
 About HTML
HTML as Hyper Text Markup Language.It is used for to create the web pages in client side/browser side.HTML is easy to learn.

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

Example:

<html>
<body>

<h1>Welcome to Online tutorials</h1>

<p>Welocme</p>

</body>
</html>

TEMPERATURE BASED FAN SPEED CONTROL

TEMPERATURE BASED FAN SPEED CONTROL

This project is a standalone Temperature based fan speed controller that controls the speed of the fan according to our requirement. Use of embedded technology makes this closed loop feedback control system efficient and reliable. Micro controller (AT89C51) allows dynamic and faster control. Liquid crystal display (LCD) makes the system user-friendly. It is very compact using few components and can be implemented for several applications including air-conditioners, water-heaters, snow-melters, ovens, heat-exchangers, mixers, furnaces, incubators, thermal baths and veterinary operating tables. AT89C51 micro controller is the heart of the circuit as it controls all the functions.

The temperature sensor LM35 senses the temperature and converts it into an electrical (analog) signal, which is applied to the micro controller through ADC. The analog signal is converted into digital format by the analog-to-digital converter (ADC). The sensed and set values of the temperature are displayed on the 16x2-line LCD. The micro controller drives control relays by means of ULN driver circuit to control the motor speed with the help of high wattage tagged wire wound resistor.

The micro controller controls FAN Speed through a ULN driver circuit. The Speed is controlled with the help of PWM technique.

This project uses regulated 5V, 500mA & 12V, 500mA power supply. 7805 and 7812 three terminal voltage regulators are used for voltage regulation. Bridge type full wave rectifier is used to rectify the ac out put of secondary of 230/12V step down transformer. This project is useful in process industries for maintenance and controlling of Boilers temperature.






HARDWARE REQUIREMENTS:
1.      AT89S52
2.      REGULATED POWER SUPPLY
3.      LM35
4.      ADC MCP3208
5.      16*2 LCD Display
6.      DC FAN
7.      ULN2003 CURRENT DRIVER
SOFTWARE REQUIREMENTS:
  1. Keil Compiler
  2. ucFlash
  3. Embedded C Code