java basics

4
What Is an Object? An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner. What Is a Class? A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior. Methods ("member functions") are similar to functions, they belongs to classes or objects and usually expresses the verbs of the objects/class. For example, an object of type Scanner usually would have methods next() and nextInt() which do corresponding operations to the object they belong. Encapsulation enforces modularity Encapsulation refers to the creation of self-contained modules that bind processing functions to the data. These user-defined data types are called "classes," and one instance of a class is an "object." For example, in a payroll system, a class could be Manager, and Pat and Jan could be two instances (two objects) of the Manager class. Encapsulation ensures good code modularity, which keeps routines separate and less prone to conflict with each other. Inheritance passes "knowledge" down Classes are created in hierarchies, and inheritance lets the structure and methods in one class pass down the hierarchy. That means less programming is required when adding functions to complex systems. If a step is added at the bottom of a hierarchy, only the processing and data associated with that unique step must be added.

Upload: john-paulo-rodriguez

Post on 21-Jul-2016

4 views

Category:

Documents


0 download

DESCRIPTION

Java Basics

TRANSCRIPT

Page 1: Java Basics

What Is an Object?

An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner.

What Is a Class?

A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.

Methods ("member functions") are similar to functions, they belongs to classes or objects and usually expresses the verbs of the objects/class. For example, an object of type Scanner usually would have methods next() and nextInt() which do corresponding operations to the object they belong.

Encapsulation enforces modularityEncapsulation refers to the creation of self-contained modules that bind processing functions to the data. These user-defined data types are called "classes," and one instance of a class is an "object." For example, in a payroll system, a class could be Manager, and Pat and Jan could be two instances (two objects) of the Manager class. Encapsulation ensures good code modularity, which keeps routines separate and less prone to conflict with each other.

Inheritance passes "knowledge" downClasses are created in hierarchies, and inheritance lets the structure and methods in one class pass down the hierarchy. That means less programming is required when adding functions to complex systems. If a step is added at the bottom of a hierarchy, only the processing and data associated with that unique step must be added. Everything else above that step is inherited. The ability to reuse existing objects is considered a major advantage of object technology.

Polymorphism takes any shapeObject-oriented programming lets programmers create procedures for objects whose exact type is not known until runtime. For example, a screen cursor may change its shape from an arrow to a line depending on the program mode. The routine to move the cursor on screen in response to mouse movement can be written for "cursor," and polymorphism lets that cursor take simulating system behaviour.

Java has significant advantages over other languages that make it suitable for any programming task.

The advantages of Java are:

Page 2: Java Basics

1. Java is easy to learnJava was designed to be easy to use and is therefore much more easy to write, compile, debug, run and learn than other programming languages.

2. Java is object-orientedThis allows you to create modular maintainable applications and reusable code.

3. Java is platform-independentOne of the most significant advantages of Java is its ability to move easily from one system to another. The ability to run the same code on many different systems is crucial to www, and Java succeeds at this by being platform-independent at the source and almost binary levels.

4. Java is distributedJava is designed to make distributed computing easy with the networking capability that is inherently integrated into it. Writing network programs in Java is like sending and receiving data to and from a file.

5. Java is secureJava considers security as part of its design. The Java language, compiler, interpreter, and runtime environment were each developed with security in mind.

6. Java is robust Robust means reliability. Java puts a lot of emphasis on early checking for possible errors, as Java compilers are able to detect many problems that would first show up during execution time in other languages.

7. Java is multithreadedMultithreaded is the capability for a program to perform several tasks simultaneously within a program. In Java, multithreaded programming has been smoothly integrated into it, while in other languages, operating system-specific procedures have to be called in order to enable multithreading.Because of Java's robustness, ease of use, cross-platform capabilities and security features, it has become a language of choice for providing worldwide Internet solutions..

Year Name Chief developer, Company Predecessor(s)

2000

C#Anders Hejlsberg, Microsoft (ECMA)

C, C++, Java, Delphi, Modula-2

2001

Visual Basic .NET

Microsoft Visual Basic

2006

Windows PowerShell

Microsoft C#, ksh, Perl, CL, DCL, SQL

200 Go Google C, Oberon, Limbo

Page 3: Java Basics

9

2009

CoffeeScript Jeremy Ashkenas JavaScript, Ruby, Python, Haskell

2010

Chapel Brad Chamberlain, Cray Inc. HPF, ZPL

2010

Rust Graydon Hoare, Mozilla

Alef, C++, Camlp4, Common Lisp, Erlang, Hermes, Limbo, Napier, Napier88, Newsqueak, NIL, Sather, Standard ML

2011

Ceylon Gavin King, Red Hat Java

2011

Dart Google Java, JavaScript, CoffeeScript, Go

2011

Elm Evan Czaplicki Haskell, Standard ML, OCaml, F#

2011

Red Nenad Rakocevic REBOL, Scala, Lua

2012

TypeScript Anders Hejlsberg, Microsoft JavaScript, CoffeeScript