Thursday, 27 August 2015

Inheritance:
Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another. With the use of inheritance the information is made manageable in a hierarchical order.
The class which inherits the properties of other is known as subclass (derived class, child class) and the class whose properties are inherited is known as superclass (base class, parent class).

extends Keyword

extends is the keyword used to inherit the properties of a class. Below given is the syntax of extends keyword.
class Super{
.....
.....
}

class Sub extends Super{
.....
.....

}

Sample Code

Below given is an example demonstrating Java inheritance. In this example you can observe two classes namely Calculation and My_Calculation.
Using extends keyword the My_Calculation inherits the methods addition() and Subtraction() of Calculation class.
Copy and paste the program given below in a file with name My_Calculation.java
class Calculation{ 
   int z;
   public void addition(int x, int y){
      z=x+y;
      System.out.println("The sum of the given numbers:"+z);
   }
   public void Substraction(int x,int y){
      z=x-y;
      System.out.println("The difference between the given numbers:"+z);
   }
   
}

public class My_Calculation extends Calculation{    
  
   public void multiplication(int x, int y){
      z=x*y;
      System.out.println("The product of the given numbers:"+z);
   }
   public static void main(String args[]){
      int a=20, b=10;
      My_Calculation demo = new My_Calculation();
      demo.addition(a, b);
      demo.Substraction(a, b);
      demo.multiplication(a, b);      
      
   }

}
What is Decision making in java?
Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
Following is the general form of a typical decision making structure found in most of the programming languages:
Learn  more Click here
Java Tutorial

Wednesday, 15 July 2015

Overloading Methods

In the Simple theory is that the same name method is use two or more than in a CLASS but the Data type and the number of argument should be different always.
In Java it is possible to define two or more methods within the same class that share the
same name, as long as their parameter declarations are different. When this is the case, the
methods are said to be overloaded, and the process is referred to as method overloading. Method overloading is one of the ways that Java supports polymorphism. If you have never used a language that allows the overloading of methods, then the concept may seem strange at first. But as you will see, method overloading is one of Java’s most exciting and useful features.
                          When an overloaded method is invoked, Java uses the type and/or number of arguments as its guide to determine which version of the overloaded method to actually
call. Thus, overloaded methods must differ in the type and/or number of their parameters.
While overloaded methods may have different return types, the return type alone is insufficient to distinguish two versions of a method. When Java encounters a call to an
overloaded method, it simply executes the version of the method whose parameters match
the arguments used in the call.

Here is a simple example that illustrates method overloading:
// Demonstrate method overloading.
class Demo {
void test() {
System.out.println("No parameters");
}
// Overload test for one integer parameter.
void test(int a) {
System.out.println("a: " + a);

}
// Overload test for two integer parameters.
void test(int a, int b) {
System.out.println("a and b: " + a + " " + b);
}
// overload test for a double parameter
double test(double a) {
System.out.println("double a: " + a);
return a*a;
}
}
class Overload {
public static void main(String args[]) {
OverloadDemo ob = new OverloadDemo();
double result;
// call all versions of test()
ob.test();
ob.test(10);
ob.test(10, 20);
result = ob.test(123.25);
System.out.println("Result of ob.test(123.25): " + result);
}

}

OUTPUT:

No parameters
a: 10
a and b: 10 20
double a: 123.25

Result of ob.test(123.25): 15190.5625

As you can see, test( ) is overloaded four times. The first version takes no parameters,
the second takes one integer parameter, the third takes two integer parameters, and the
fourth takes one double parameter. The fact that the fourth version of test( ) also returns a
value is of no consequence relative to overloading, since return types do not play a role in
overload resolution.
When an overloaded method is called, Java looks for a match between the arguments
used to call the method and the method’s parameters. However, this match need not always

be exact. In some cases, Java’s automatic type conversions can play a role in overload resolution.
HOW TO CREATE JAVA ENVIRONMENT IN WINDOW 7/8/8.1.



Step 1: First make to download the jdk(Java Development Kit). From the Oracle Site for the appropriate system 64bit or 32bit. 

 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
                
Step 2:  If you do not have the IDE of java. You can download the IDE (Eclipse) as a compiler.
You can download from here for your appropriate windows need.
https://eclipse.org/downloads/packages/release/juno/sr2.

                             OR

If you do not want to download eclipse you can write the program in notepad but i am suggested that it is the best or time saving is to work on IDE.

Step 3:  If you download the IDE you can start work on it. Or if you donot download and work on notepad. Than you must go in the                     

  • PROGRAM FILE
  • In JAVA 
  • Go to BIN folder
  • open the PROPERTIES of First APPLET FILE.
  • Copy the PATH of the APPLET FILE.
  • Go to the MY COMPUTER PROPERTIES.
  • Than GO In the ADVANCE SETTING SYSTEM.
  • Than go in the ENVIRONMENT VARIABLES.
  • Go to the NEW and NAME ALOT as PATH and PASTE the Path of applet file and save.
  • Than you go in COMMAND PROMPT and Write java
  • Than you got the details of the java.
write the program in NOTEPAD.
EXAMPLE::

class TEST{
public static void main(String args[]){
System.out.println("Hello World");
}
}



  • Save this file as the same name of the class name.
  • than save as TEST.JAVA on the desktop.
  • and Than go to Command Prompt
  • Write javac TEST.JAVA{For the compile and check errors in the program}.
  • than you want to run you can write as java TEST.

Java World: How to resolve merge conflicts after git rebase ?

Java World: How to resolve merge conflicts after git rebase ?

Tuesday, 14 July 2015

LOOP CONTROL:

There may be a situation when we need to execute a block of code several number of times and is often referred to as a loop. Java has very flexible three looping mechanisms. You can use one of the following three loops: 

  1.  while Loop 
  2.  do...while Loop 
  3.  for Loop
while Loop:

A while loop is a control structure that allows you to repeat a task a certain number of times.
While loop always check before entering the loop is that the condition is to be true or not.

Syntax

while(boolean Experssion){
//statements//
}

do...while Loop: 

A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.
In do while first time do loop goes but after completing the one time run they check the for loop is true or not if not true they go out from the loop
THE MAIN DIFFERENCE IS THAT BETWEEN While AND Do...While LOOP.

Syntax

do{
//statements//
}
while(boolean Expression);

For Loop:

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. A for loop is useful when you know how many times a task is to be repeated. 

Syntax

for(initialize;boolean expression;increment/decrement){
//statement//
}

Monday, 13 July 2015

Access Control Modifiers: 


Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are: 

  • Visible to the package. the default. No modifiers are needed.  Visible to the class only (private). 
  •  Visible to the world (public). 
  • Visible to the package and all sub-classes (protected). 


Non Access Modifiers: Java provides a number of non-access modifiers to achieve many other functionality. 

  • The static modifier for creating class methods and variables 
  • The final modifier for finalizing the implementations of classes, methods, and variables. 
  • The abstract modifier for creating abstract classes and methods.

Java Operators::-
  1.  Arithmetic Operators 
  2.  Relational Operators 
  3.  Bit-wise Operators 
  4.  Logical Operators 
  5.  Assignment Operators 
  6.  Misc Operators.

Thursday, 9 July 2015

Arrays

An array is a indexing form of data. A specific element in an array is accessed by its index. Arrays offer a convenient means of grouping related information.

An array is a group of like-typed variables that are referred to by a common name. Arrays of
any type can be created and may have one or more dimensions. A specific element in an array is accessed by its index. Arrays offer a convenient means of grouping related information.
ARRAY will be initialized as :

ar[5]={"name","class","roll_no","marks","regd_no"};

Another type of initialization of an array

int a[5];
in FOR LOOP we can access as

Scanner z=new Scanner (System.in);//Input at the run time from the user
for(int i=0;i<=5;i++){
a[i]=z.next();
system.out.println(a[i]);
}

Definition of the methods and keywords use in the Programm

public static void main(String [ ]args)

public means which can access from anywhere in the class

static means which can loaded as first in the class.

void all know about is it. Its is no return type.

main means they first find the main method of the class where is the main method of the                  class.
             main always in small alphabetic form because it is case sensitive and can not know              about MAIN.
String means they get the string form of the data as like "NAME".

args[ ] this is defined as because of storing and accessing the data of the array stored in the heap memory.

System.out.println("HELLO WORLD");

System is the class which is in-build in the jdk{(java development kit) which provide enviroment of the system} and "s" of the system is to be capital always.

out it is the object of the system class.

println is the method which is used to print the string on the console
             normal print is used to print string in a line whenever println is used to change the                  line in next line.


Tuesday, 7 July 2015

Primitive Types


  • Integer - Group which includes byte, short, int, and long, which are for whole-value signed numbers.
  • Floating-  This group includes float and double.
  • Characters -This group includes char, which represents symbols in a character set, like letters and numbers.
  •  Boolean -This group includes boolean which is a special type for representing true/false values.

Integers
Java defines four integer types: byte, short, int, and long. All of these are signed, positive
and negative values. Java does not support unsigned, positive-only integers. Many other
computer languages support both signed and unsigned integers. However, Java’s designers
felt that unsigned integers were unnecessary. Specifically, they felt that the concept of unsigned was used mostly to specify the behavior of the high-order bit, which defines the sign of an integer value. As you will see in Chapter 4, Java manages the meaning of the high-order bit differently, by adding a special “unsigned right shift” operator. Thus, the need for an unsigned integer type was eliminated.

The width of an integer type should not be thought of as the amount of storage it consumes,
but rather as the behavior it defines for variables and expressions of that type. The Java run-time environment is free to use whatever size it wants, as long as the types behave as you declared them.

byte
The smallest integer type is byte. This is a signed 8-bit type that has a range from –128 to 127. Variables of type byte are especially useful when you’re working with a stream of data from a network or file. They are also useful when you’re working with raw binary data that may not be directly compatible with Java’s other built-in types.
Byte variables are declared by use of the byte keyword. For example, the following
declares two byte variables called b and c: 
byte b, c;


short
short is a signed 16-bit type. It has a range from –32,768 to 32,767. It is probably the least-used Java type. Here are some examples of short variable declarations:
short s;
short t;

int
The most commonly used integer type is int. It is a signed 32-bit type that has a range
from –2,147,483,648 to 2,147,483,647. In addition to other uses, variables of type int are
commonly employed to control loops and to index arrays. Although you might think that
using a byte or short would be more efficient than using an int in situations in which the
larger range of an int is not needed, this may not be the case. The reason is that when byte
and short values are used in an expression they are promoted to int when the expression is
evaluated. (Type promotion is described later in this chapter.) Therefore, int is often the best
choice when an integer is needed.

long
long is a signed 64-bit type and is useful for those occasions where an int type is not large
enough to hold the desired value. The range of a long is quite large. This makes it useful
when big, whole numbers are needed. For example, here is a program that computes the
number of miles that light will travel in a specified number of days.



FLOATING
The type float specifies a single-precision value that uses 32 bits of storage. Single precision is faster on some processors and takes half as much space as double precision, but will become imprecise when the values are either very large or very small. Variables of type float are useful when you need a fractional component, but don’t require a large degree of precision. For example, float can be useful when representing dollars and cents.
Here are some example float variable declarations:

float hightemp, lowtemp;


double
Double precision, as denoted by the double keyword, uses 64 bits to store a value. Double
precision is actually faster than single precision on some modern processors that have been
optimized for high-speed mathematical calculations. All transcendental math functions, such
as sin( ), cos( ), and sqrt( ), return double values. When you need to maintain accuracy over

BASIC SYNTAX OF JAVA

public class myfirstprogram{

public static void main(String args[]){

system.out.println("HELLO WORLD");

}
}

Monday, 6 July 2015


The Evolution of Java: Past, Present, and Future


Java was started as a project called "Oak" by James Gosling in June 1991. Gosling's goals were to implement a virtual machine and a language that had a familiar C-like notation but with greater uniformity and simplicity than C/C++. The first public implementation was Java 1.0 in 1995. It made the promise of "Write Once, Run Anywhere", with free run-times on popular platforms. It was fairly secure and its security was configurable, allowing for network and file access to be limited. The major web browsers soon incorporated it into their standard configurations in a secure "applet" configuration. popular quickly. New versions for large and small platforms soon were designed with the advent of "Java 2". Sun has not announced any plans for a "Java 3".


In 1997, Sun approached the ISO/IEC JTC1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. Java remains a proprietary de facto standard that is controlled through the Java Community Process. Sun makes most of its Java implementations available without charge, with revenue being generated by specialized products such as the Java Enterprise System. Sun distinguishes between its Software Development Kit (SDK) and Runtime Environment (JRE) which is a subset of the SDK, the primary distinction being that in the JRE the compiler is not present.
JDK(JAVA DEVELOPMENT KIT) the latest version of JDK is 8.1 now a days and IDE
which is best for compile the program is Eclipse Luna and Juna you can download from any site which is open source.


JAVA APPLICATION

Java Application are two types-
1. That application work on the system only.
2.Java Applet which works on the internet through server.

Sunday, 5 July 2015

JavaCHARACTERISTICS AND FEATURES


                 Features of Java Programming Language
  • 1. Simple :
  • 2. Secure :
  • 3. Portable :
  • 4. Object-oriented :
  • 5. Robust :
  • 6. Multi-threaded :
  • 7. Architecture-neutral :
  • 8. Interpreted :
  • 9. High performance :
  • 10. Distributed :
  • Dynamic :    
           ____________________________________________________________________
           ------------------------------------------------------------------------------------------------------
  • Simple :

    • Java is Easy to write and more readable and eye catching.
    • Java has a concise, cohesive set of features that makes it easy to learn and use.
    • Most of the concepts are drew from C++ thus making Java learning simpler.

    Secure :

    • Java program cannot harm other system thus making it secure.
    • Java provides a secure means of creating Internet applications.
    • Java provides secure way to access web applications.

    Portable :

    • Java programs can execute in any environment for which there is a Java run-time system.(JVM)
    • Java programs can be run on any platform (Linux,Window,Mac)
    • Java programs can be transferred over world wide web (e.g applets)

    Object-oriented :

    • Java programming is object-oriented programming language.
    • Like C++ java provides most of the object oriented features.
    • Java is pure OOP (Object Oriented Program). Language. (while C++ is semi object oriented)

    Robust :

    • Java encourages error-free programming by being strictly typed and performing run-time checks.

    Multi-threaded :

    • Java provides integrated support for multi-threaded programming.

    Architecture-neutral :

    • Java is not tied to a specific machine or operating system architecture.
    • Machine Independent i.e Java is independent of hardware .

    Interpreted :

    • Java supports cross-platform code through the use of Java byte-code.
    • Byte-code can be interpreted on any platform by JVM.

    High performance :

    • Byte-codes are highly optimized.
    • JVM (Java Virtual Machine)can executed them much faster .

    Distributed :

    • Java was designed with the distributed environment.
    • Java can be transmit,run over internet. 
       Dynamic :
  •   Java programs carry with them substantial amounts of run-time type information that is used to verify and resolve accesses to objects at run time.

Friday, 3 July 2015

Java is one of the best language of Programming in the World.
It is very safe and secure language.

Why it is safe and secure language?
This language contains String keyword which have one statement.
that if u declare string as final so you dont extend the class and make secure data.

Java use in everywhere.
Banks-to secure the management of money
   

Thursday, 2 July 2015

Originally known as oak, Java is a programming language developed by James Gosling and others at Sun Micro-systems.
That was first introduced to the public in 1995 and today is widely used to create Internet applications and other software programs. Today, Java is maintained and owned by Oracle.
When used on the Internet, Java allows applets to be downloaded and used through a browser, which enables the browser to perform a function or feature not normally available. Unlike JavaScript, the users must download or install the applet or program before being able to utilize the Java program.
Below is an example of a Java applet from Sun and a method of testing if Java is installed on your computer. If Java is installed on your computer, you should see additional information about the installed Java version and your operating system.

Java is also used as the programming language for many different software programs, games, and add-ons. Some examples of the more widely used programs written in Java or that use Java include Adobe Creative Suite, Eclipse, Lotus Notes, Minecraft, OpenOffice, Runescape, and Vuze.