Data Types and variables in Java

datatypes

Data Types

  • The term data type refers to the type of data that can be stored in a variable.
  • Sometimes,java is called a "strongly typed language"because when you declare a variable,you must specify the variable's type.
  • Then the compiler  ensures that you don't try to assign data of the wrong type to the variable. 

Variables

Variable is name of reserved area allocated in memory
There are 3 types of  variables in Java
  1. Local variable
  2. Static variable
  3. Instance Variable.
Local Variable
A variable that is declared inside the method is called local variable.

Static Variable
A variable that is declared as static is called static variable. It cannot be local.


Instance Variable
A variable that is declared inside the class but outside the method is called instance variable.
It is not declared as Static.

Basics of Java


Syntax of Java

About java programs,it is very important to keep in mind the following points

Case Sensitivity

Java is case sensitive which means identifier Hello and hello would have different meaning java.

Class Name

For all class names the first letter should be in Upper Case.
I. If several words are used to form a name of the class ,each inner word's first letter should be in Upper case.
II. Example class MyFirstJavaClass

Method Name

All method names should start with a Lower case letter.
I. If several words are used to form the name of the method,then each inner word's first letter should in Upper case.
II.Example public void myMethodName()

Program File Name

Name of the program file should exatly match the class nae.
I. When saving the file,youshould save it using the class name and append'.Java'to the end of the name.
II. Example : Assume 'MyFirstJavaProgram'is the class name. Then the file should be saved as "MyFirstJavaProgram.java"

public static void main(String args[])

Java program processing starts from the main() method which is a mandatory part of every Java program.

Comments in Java

The java language supports three types of comments
/*text*/ the compiler ignores everything from?8 to */ /**documentation**/ This indicates a documentation comment.comment. The compiler ignores this kind of comment, just like it ignores comments that use /*and*/.The JDK java doc tool uses doc comments when preparing automatically generated documentation. //text The compiler ignores everything from // to the end of the line.

Reserved keywords in Java

Keywords are special tokens in the language which have reserved use in the language. Keywords may not be used as identifier in Java. You cannot declare a field whose name is a keyword ,for instance

Html introduction

What is HTML ?

HTML is a markup language for describing web documents (web pages)
--> HTML stands for Hyper Text Markup Language. HTML adds "markup" to Standard English text." Hyper Text" refers to links -hyperlinks-that connect web pages to one another.
 --> A markup language is a set of markup tags.
 -->HTML documents are described by HTML tags.
 --> Each HTML tag describes different document content.
 --> HTML is not case sensitive.

History of Html ?

HTML is an evolving language. It doesn't stay the same for long before a revised set of standards nd specifications are brought in to allow easier creation of prettier and more efficient sites.
HTML 1.0
The Hyper Text Markup Language was the brainchild of Sir Tim Berners-Lee.In 1991 he wrote a document called "HTML tags" in which he proposed fewer than two dozen elements that could be used for writing web pages.
HTML 2.0
HTML 2.0 included everything from the original 1.0 specification but added a few new features to mix. HTML 2.0 was the standard for website design until January 1997 and defined many core HTML features for the first time.
HTML 4.0
HTML 4.0 was recommended by the W3C in December'97 and became the official standard in April 1998. Browser support was undertaken surprisingly earnestly by Microsoft in their internet Explorer browser. HTML 4.0 was large evolution of HTML standards ,and the last iteration of classic HTML.
XHTML 1.0
This is the successor to HTML. The "X"stands for Extensible.This, is a reformulation of HTML 4.01 with in XML which is far more rigorous, and is intended to start moving the creation of web pages away from HTML.
HTML 5
HTML 5 was finialized and published on 28 October 2014 by the world Wide Web Consortium(W3C). This is the fifth version of the HTML standard since the inception of the World Wide Web.

Advantages of HTML


  1. Easy To Use. Loose Syntax. 
  2. Supported on almost every browser. 
  3. Widely used, established on almost every website. 
  4. Very similar to XML syntax,which is increasingly used for data storage.
  5.  Free-You need not buy any software. 
  6. Easy to learn & code even for novice programmers.

Dis advantages of HTML

  1. It cannot produce dynamic output alone since it is a static language.
  2. Security features offered by HTML are limited.
  3. Sometimes,the structuring of HTML documents is hard to grasp.

short cut keys of Tally

FUNCTION KEYS


F1: To Select a Company/Inventory Button/Payment Voucher.
F2: To Change Current Date.
F3: Select the company.
F4: To Select the contra voucher. Voucher creation and alteration screen.
F5: To select the payment creation Voucher.Voucher creation and alteration screen.
F6: To Select the Receipt. Voucher creation and alteration screen.
F7: To Select the Journal voucher. Voucher creation and alteration Screen.
F8: To Select the Sales Voucher. Voucher creation and alteration screen.
F9: To Select the purchase Voucher.Voucher creation and alteration screen.
F10: To Select the reversing Journal Vouchers. Voucher creation and alteration screen.
F11 : To Select the Functions and features screen. Voucher creation and alteration screen.
F12: To Select the configure screen.

ALT+ KEYS


Alt + A:  To Add a voucher ,to alter a column in column report.
Alt+  C: To create a master at voucher screen.
Alt + D: To Delete Voucher/Masrer/Column.
Alt+ E: To Export the Report in Excel,Html,XML Formats.
Alt + I : To insert a Voucher.
Alt + K : To select the keyboard configuration.
Alt + L : To select the language configuration.
Alt + M : To email the Report.
Alt + N: To view the report in automatic columns.
Alt+  O : To upload the report at your website.
Alt + P: To print the Report.
Alt + R: To remove line in a report.
Alt + S : To bring a back line you removed using Alt + R.
Alt + U : To retrieve the last line you removed using Alt + R.
Alt + V: From invoice screen to bring stock journal screen.
Alt + W; To view the Tally web Browser.
Alt + X; To cancel a voucher in Day Book/List of Voucher.
Alt + F1: To Select company.To select inventory vouchers to alter.To view detailed Report.
Alt + F2:  To Change period
Alt + F3: To select the company info menu for create/alter.
Alt + F4: To select the purchase order Voucher type.
Alt +F5 : To select the sales order voucher type.
Alt + F6:  To select the rejection out voucher. To change sales order voucher type.
Alt + F7 : To select the stock journal voucher type.
Alt + F8: To select the delivery note voucher note type.
Alt + F9: To select the receipt note voucher type.
Alt + F10 : To select the physical stock voucher type.
Alt + F12: To filter the information based on the monetary value.

c tokens keywords and identifiers


Tokens are Building Blocks of C programming.




Token Definations

Keyword: A variable is meaningful of data storage in computer memory. when using a variable you refer to memory address  of computer.
Constants:Constants are expressions with a fixed value.
Identifiers: The term identifier is usually used for variable name.
String: Sequence of characters.
Operators: A symbol that represent mathematical or non-mathematical operation.
Special symbols: Symbols other than alphabets digits and whites paces.

Token Example

SNo Token Type Example1 Example2
1 keyword for switch
2 constants number Sum
3 Identifier -120 14
4 string "abc" "prni"
5 operators ++ --
6 special symbols * @


Keywords of C programming language
  1. keywords already defined by compiler.
  2. Cannot be used as a variable name.
  3. There are 32 keywords in c.
  4. Those are also known as Reserved keywords.
32 keyword of c language


auto double struct int
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
7Search.com - Affordable PPC Advertising - Quality Traffic and Low Bid Prices Equal a Better ROI


Variables in C

Variable in c is also called as Container to store the data
Variable name may have different datatypes to identify the type of value to stored.
Suppose we declare variable of type integer then it can store only integer values
A variable is a name given to the meory location whre the actual data is stored

Rules for Constructing variable in c

  1. Characters allowed: Underscore(_),Capital Letters(A-Z),Small Letters(a-z),and digits(0-9).
  2. Blank spaces and commas are not allowed.
  3. No special symbols other than Underscore (_) not allowed.
  4. First character should be alphabet or Underscore.
  5. Variable name should not be reserved keywords.
Variable declaration in c
  • To declare is nothing but represent variable.
  • Only variable name and its datatype is represent at declaration
  • Declaration is used for identification of data type.
Examples of Declartion
int var;Here int is Integer datatype var is the variable name
float var; var is floating data type.
char var; var is here character data type.
Types of Variable in C
  1.  Local variable 
  2. Global variable
Local Variables
  1. Local variable is having local scope.
  2. Local variable is accessible form function only or block in in which it is created.
  3. Local variable is given higher priority than the global variable.
Global variables
  1. Global variable is variable that is globally available.
  2. Scope of Global variable is throughout the program.[i.e all functions including main()]
  3. Global variable is also visible inside function,provides  that it should not declared " High priority is given to local variable than Global
  4. Global variable can be accessed form any function

Number Java Programs

Write a java program to check Armstrong Number?

import java.util.*;
class ArmstrongNumber
{
   public static void main(String args[])
   {
    int n=,sum=0,temp,r;
    Scanner in=new Scanner(System.in);
    System.out.println("Enter a number to check if it is an armstrong number");
    n=in.nextInt();
    temp=n;
    while(temp!=0)
    {
       r=temp%10;
      sum=sum+r*r*r;
      }
      if(n=sum)
       System.out.println("Entered number is an armstrong number");
      else
      System.out.println("Entered number is not an armstrong number");
   }

}

earn money online earn money earn money survey earn money from home earn money typing earn money at home photoshop tutorial web site design tutorial free web design tutorial c tutorial java program programming language jdk in java bloger help monteize blog OUTPUT
Enter a number to check if it is an armstrong number
153
Entered number is an armstrong number

Write a java program to print Factorial Number?

import java.util.Scanner;
public class Factorial
{
   public static void main(String args[])
   {
      int fact=1;
      int number=0;
      System.out.println("Enter a number to its factorial ");
      Scanner in=new Scanner(System.in);
      number=in.nextInt();
      for(int i=1;i<=number;i++)
      {
         fact=i*fact;
       }
     System.out.println("the factorial of "+number+"is"+fact);
   }
}
Enter a number to print its factorial
6
The factorial of 6 is 720

Write a Java program to print Fibonacci Series?

import.java.io.*;
import.java.lang.*;
class Fibonacii
{
    public static void main(String args[])
     {
       int n1=0,n2=1,n3,i,count=10;
       System.out.println(n1+" "+n2);//printing 0 and 1
       for(i=2;i<count;i++)
       {
         n3=n1+n2;
         System.out.print(" "+n3);
         n1=n2;
         n2=n3;
        }
     }
}

OUTPUT


0 1 1 2 3 5 8 13 21 34
Write a java program to print given number is even or odd ?

import.java.util.Scanner;
class OddOrEven
{
   public static void main(String args[])
   {
     int a;
     System.out.println("Enter an integer to check if it is even or odd");
     Scanner in=new Scanner(System.in);
     X=in.nextInt();
     if(a%2 == 0)
     System.out.println("You entered number is even")
     else
     System.ou.println("You entered number is Odd");
} }
OUTPUT
Enter an integer to check if it is even or odd
52
You entered number is Even

Explain about JDK , JVM in Java

  jdk in java ,JRE and JVM

JRE:  Java Run time Environment ,It is used to provide run time environment. It is the implementation of JVM. It physically exists. It contains of set of libraries + other files.
JDK:  Java Development Kit it physically exists. It contains JRE+ development tools.

JVM :  Java virtual Machine it is a specification that provides run time environment.

JVM Performs the Loads code,Verifies Code,Executes Code.

Internal Architecutre of JVM
  1. Class Loader: class loader loads the class files.
  2. Class(Method) Area: This stores per class structures such as the run time constant pool field and method data the code for methods.
  3. Heap:It is the run time data area in which objects are allocated.
  4. Stack: Java Stack stores frames.It holds local variables and partial results.
  5. Program Counter Register(PC):It contains the address of the Java Virtual Machine instruction currently being executed.
  6. Native Method Stack:It contains the all the native methods.
  7. Execution Engine:  It contains  Virtual Processor, Interpreter,Just In Time Compiler(JIT)