Вы находитесь на странице: 1из 5

Java IMP points

Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991. It took 18 months to develop the first working version. This language was initially called Oak but was renamed Java in 1995. Bill Joy, Arthur van Hoff, Jonathan Payne, Frank Yellin, and Tim Lindholm were key contributors to the maturing of the original prototype. Although it is possible to compile a C++ program for just about any type of CPU, to do so requires a full C++ compiler targeted for that CPU. The problem is that compilers are expensive and timeconsuming to create. An easier and more cost-efficientsolution was needed. In an attempt to find such a solution, Gosling and others began work on a portable, platform-independent language that could be used to produce code that would run on a variety of CPUs under differing environments. This effort ultimately led to the creation of Java. Security : java will provided a security from downloading the softwares , files from web, which is accomplished by providing firewall between network and user computer.

Buzzwords: Simple Secure Portable Object-oriented Robust Multithreaded Architecture-neutral Interpreted High performance Distributed

Robust : force you to find your mistakes early in program development

All object-oriented programming languages provide mechanisms that help you implement the object-oriented model. They are encapsulation, inheritance, and polymorphism. Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. One way to think about encapsulation is as a protective wrapper that prevents the code and data from being arbitrarily accessed by other code defined outside the wrapper. Access to the code and data inside the wrapper is tightly controlled through a well-defined interface.

In Java the basis of encapsulation is the class.

A class defines the structure and behavior (data and code) that will be shared by a set of objects. Each object of a given class contains the structure and behavior defined by the class, as if it were stamped out by a mold in the shape of the class. For this reason, objects are sometimes referred to as instances of a class. Thus, a class is a logical construct; an object has physical reality. The public interface of a class represents everything that external users of the class need to know, or may know. The private methods and data can only be accessed by code that is a member of the class. Therefore, any other code that is not a member of the class cannot access a private method or variable. Inheritance is the process by which one object acquires the properties of another object. Polymorphism (from the Greek, meaning many forms) is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation.

Ability to create robust programs was given a high priority in the design of Java. To gain reliability, Java restricts you in a few key areas, to force you to find your mistakes early in program development. At the same time, Java frees you from having to worry about many of the most common causes of programming errors. Because Java is a strictly typed language, it checks your code at compile time.

Java is case-sensitive. Java programs are a collection of whitespace, identifiers, comments, literals, operators, separators, and keywords. Identifiers: Identifiers are used for class names, method names, and variable names. An identifier may be any descriptive sequence of uppercase and lowercase letters, numbers, or the underscore and dollar-sign characters. There are three types of comments defined by Java. Single-line and multiline. The third type is called a documentation comment. This type of comment is used to produce an HTML file that documents your program. The documentation comment begins with a /** and ends with a */. Java key words: abstract, continue, goto, package, synchronized, assert, default, if, private, this, Boolean, do, implements, protected, throw, break, double, import, public, throws, byte, else, instanceof, return, transient, case extends, int, short try, catch, final, interface, static, void, char, finally, long, strictfp, volatile, class, float, native, super, while, const, for, new, switch. println( ) and print( ). As mentioned, these methods are members of the System class, which is a class predefined by Java that is automatically included in your programs. Java is a strongly typed language. Java defines eight simple (or elemental) types of data: byte, short, int, long, char, float,double, and boolean. Integers this group includes byte, short, int, and long, which are for whole valued signed numbers. Floating-point numbers this group includes float and double, which represent numbers with fractional precision.

Characters this group includes char, which represents symbols in a character set, like letters andnumbers.

Boolean this group includes boolean, which is a special type for representing true/false values. Bitwise operater Operator ~ & | ^ >> >>> << &= |= ^= >>= >>>= <<= Result Bitwise unary NOT Bitwise AND Bitwise OR Bitwise exclusive OR Shift right Shift right zero fill Shift left Bitwise AND assignment Bitwise OR assignment Bitwise exclusive OR assignment Shift right assignment Shift right zero fill assignment Shift left assignment

The System.in.read () , which is used to tack a input from the user.


Sometimes you will want to pass information into a program when you run it. This is accomplished by passing command-line arguments to main( ). A command-line argument is the information that directly follows the programs name on the command line when it is executed.

All command-line arguments are passed as strings. You must convert numeric values to their internal forms manually.

A subclass can call a constructor method defined by its superclass by use of the following form of super super(parameter-list) The second form of super acts somewhat like this, except that it always refers to the superclass of the subclass in which it is used. super.member

Dynamic Method Dispatch : Dynamic method dispatch is the mechanism by which a call to an
overridden method is resolved at run time, rather than compile time. Dynamic method dispatch is important because this is how Java implements run-time polymorphism. A superclass reference variable can refer to a subclass object. Overridden methods allow Java to support run-time polymorphism. Polymorphism is allows a general class to specify methods that will be common to all of its derivatives, while allowing subclasses to define the specific implementation of some or all of those methods. Part of the key to successfully applying polymorphism is understanding that the super classes and subclasses form a hierarchy which moves from lesser to greater specialization. Using the keyword interface, you can fully abstract a class interface from its implementation. That is, using interface, you can specify what a class must do, but not how it does it. Interfaces are syntactically similar to classes, but they lack instance variables, and their methods are declared without any body. Interfaces are designed to support dynamic method resolution at run time.

Interfaces add most of the functionality that is required for many applications which would normally resort to using multiple inheritance in a language such as C++.

Java provides the native keyword, which is used to declare native code methods. Once declared, these methods can be called from inside your Java program just as you call any other Java method.

The precise steps that you need to follow will vary between different Java environments and versions. This also depends on the language that you are using to implement the native method. The following discussion assumes a Windows 95/98/XP/NT/2000 environment. The language used to implement the native method is C.

Вам также может понравиться