Skip to main content

Posts

Decision Making and Looping

 Introduction     A computer program is well suited for perform certain operation. Every computer language or computer programe have featuer that instruct the program for repetitive task. The process of repeatedly execution of blocks of statement is known as Looping . The statement of block will execute any number of times, from zero to infinite number.   Fig.  Loop Control structure      Java supports such a looping feature. In looping, a sequence of program will executed until some condition for the termination of the loop are satisfied. So looping have two segments, Aprogram loop means its body and control statement means its condition.     The test condition should be carefully stated in order to perform the desired number of loop executions. Java language provides three constructs for looping operation.     while      do     for 1. While:         The simplest of all lo...

Decision Making and Branching Statements / Control Statements

 Introduction     Java is a set of statements which executed sequentially in the order in which they appear. This will happen when option or repetitions of certains are not necessary. However, We have a number of situation, where we may have to change the order of execution of statement on bases of certain conditions. This involves a kind of dicision making to see the particular condition occured or not and the direction of execution will execute according to it.     When program braks the sequential flow and jump on the another part of code then it's called branching . When branching is on particular condition then it's called conditional branching . If branches executes without any particular conditions then it's call unconditional branching .     Java supports such decision making capabilities and supports following statements known as Control statement or Decision making statement .     if statements     switch statement   ...

Operators and Expressions

Introduction     Java Supports  a rich set of operators.  An operator is a symbol that tells the computer to perform certain mathamatical or logical manipulataion. Operators are use in programes to manipulate data and variables. Usually it is part of mathmatical or logical expressions. There are some categories of java operators as below:     Arithmatic Opertaors     Relational Operators     Logical Operators     Assignments Operators     Increment and Decrement Operators.     Conditional Operators     Bitwise Operators     Special Operators. 1. Arithmatic Operators:     Arithmatic operators are use to construct mathemaical expressions an in algebra. Java supports all the basic arithmatic operators.     Arithmatic operators are use as below:          a-b          a-b=10          -14%3=-2 Example...

Variables and data types

 Variables and data types     A variable is an identifier that does not store location. It use to store data values. Unlike constant that remain unchange during the execution of program, but a variable may take different value or can change value different times during the execution of program.     A variable name can be chosen by programmer in meaningful way so it can reflect what it represent in the program. Some example are as follows:     average     height     total_height     classStrength     Variable name may consist of alphabets, digits, the underscore ( _ ) and dollar ( $ ) characters.  It has some conditions those are as follows:     They must not begin/start with digit.     Uppercase and lower case are distinct. That means TOTAL is not same as total .     It should not be a keyword.     White space is not allowed.     Variable name can be any len...

Constants in java

 Constants in java     Constants in java refers to fixed value in java that do not change during the execution of a program. Integer Constants:     An interger constant refers to a sequence of digits. There are three types of integers, Decimal integers, Octal integer and Hexadecimal integer. Decimal integer constant is a set of digits, o through 0, preceded by an optional min sign, Examples are:      123          -321         0          654321 Octal integer constant consists of any combination of digits from the set 0 through 7, with a leading 0. Examples are:     037            0          0453       05512 A sequence of digits preceded by 0x or 0X is considered as hexadecimal integers, they may also includes alphabets A through F or a through f . Examples are:     0x2...

Java Virtual Machine (JVM)

 Java Virtual Machine (JVM)     All language compliers translate source code into machine code for a specific computer. Java complier also do the same things but Java compiler produce an intermediate code known as bytecode . This machine is called as Java Virtual Machine(JVM) and it is exists only inside the computer memory with java. It is simulated computer within computer and does all major functions of real computer.      The virtual machine code is not machine specific. The machine specific code is generated by the  Java Interpreter by acting as an intermediary between the virtual machine and the real machine. The interpreter is different for different machine. The java object framework acts as the intermediary between the user program and virtual machine which turns act as the intermediary between operatinf system and the java object framework.

Java Tokens

 Java Tokens     A java programes is basically a collection of classes. A class is defined by a set of declaration statements and methods containing executable statements. Most statements contain expression which describe the actions carried out on data. Smallest individual units in a program are know as token. The compiler recognizes them for building up expressions and statements.     In a simple terms, a java program is a collection of tokens, comments and white spaces. Java language includes five type of token.     Reserved Keyword     Identifiers     Literals     Operators     Separators Reserved Keyword:     Keywords are an essential part of language definition.  Keywords are the words whis defination is already known to java. They implements specific featues of language. Java has 50 reserved keyword.  These keywords, combined with operators and separators according to syntax, from defin...

Java Programe Structure

 Java Programe Structure     Java class contains may classes but only one class contain main method. Class contain data members and methods that operate on the data members of the class. Method may contend data type declaration and executable statements. To write program, we first need to define classes and then put them together. A java may contain one or more sections. Document Section:     The documentation section comprises a set of comment lines giving the name of programes, author details and other details of program. Comments must explain why and what are the cases. This will help in maintaining the program. For single line comment comment programer will use ' // ' forword slash and for multiline comment programer will use ' /* */ ' syntax. Package Statement:     The first statement allowed in a java file is Package statement. This statement declares a package name and inform the compiler that class defined here belong to this package. For ex...

Object Oriented Concepts in Java (OOPS Concepts)

Java OOPS Concepts      Object oriented programing language provides many concepts, such as Inheritance, Data Binding, Polymorphism etc. Object:     Any entity which has state and behavior is known as object. It can be physical or logical part. For example, a chair, pen, keyboard etc.     An object can be define as instance of class. An object contains an address and takes up some space in memory. Objects can communicate with each other without knowing the details of each others data or code. Only the type of response and message acceptance is important. The representation of object is same as below: Class:     Class is a collection of object. It is logical entity. Class can also be define as a blueprint from which you can create individual object. Class doesn't consume any space. Sample example of java class declaration is as follows:     class SampleDemo{          // Statements or logical code   ...

Features Of Java

 Features Of Java The main objective of Java Programing was to make it portable, simple and secur programming language. The features of java language is as below. 1. Simple:        Java is very easy to learn and syntax is simple, clean and easy to understand. Java syntax is base on C++ so easier for programmers to learn it after C++. Java has removed many complicated and rarely use features for example, explicit pointer, operator overloading etc. In java, there is no need to remove unreferenced object because there is Automatic Garbage Collection in java. 2. Object Oriented:     In java the data and methods can flow in the form of object so it is call Object-oriented programing language. Object oriented programming is a methodology that simplifies software development and maintain by providing some rules. The basic concepts of OOPS are:     Object     Class     Inheritance     Ploymorphism     Abstract...