বৃহস্পতিবার, ১৪ জুলাই, ২০১১

About basic Java

What Is Java

Java is a computer programming language created by Sun Microsystems.

The Java programming language is a high-level language that can be characterized by all of the following buzzwords:

  • Simple

  • Architecture neutral

  • bject oriented

  • Portable

  • istributed

  • High performance

  • Multithreaded

  • Robust

  • Dynamic

  • Secure

Why Java is so popular

1. It is free unlike the other rivals.

2. Platform independence (Write Once Run Anywhere).

3. Automatic Garbage collection (Memory management)


Java Object: Object is a real time entity and it has state and behavior.

Java Class: Java class is a blue print of java object.

Abstract class: Abstract classes are super classes which contain abstract methods and are defined such that concrete subclasses are to extend them by implementing the methods.

Concrete class: A concrete class, however, is a class for which entities (instances) may be created. This contrasts with abstract classes which can not be instantiated because it defeats its purpose of being an 'abstract'.


Identifiers:

1. Identifiers must start with a letter, a currency character ($), or a connecting
character such as the underscore ( _ ). Identifiers cannot start with a number!
2. After the first character, identifiers can contain any combination of letters,
currency characters, connecting characters, or numbers.
3. In practice, there is no limit to the number of characters an identifier can
contain.
4. You can't use a Java keyword as an identifier. Table 1-1 lists all of the Java
keywords including one new one for 5.0, enum.
5. Identifiers in Java are case-sensitive; name and NAME are two different identifiers.


JavaBeans: JavaBeans are Java classes that have properties with setter and getter.


JavaBean Property Naming Rules:

1. If the property is not a boolean, the getter method's prefix must be get. getSize()

2. If the property is a boolean, the getter method's prefix is either get or is .getStopped() or isStopped()

3. The setter method's prefix must be set. setSize()

4. Setter method signatures must be marked public, with a void return type
and an argument that represents the property type.

5. Getter method signatures must be marked public, take no arguments, and
have a return type.

Source File Declaration Rules


1. There can be only one public class per source code file.
2. Comments can appear at the beginning or end of any line in the source code
file.
3. If there is a public class in a file, the name of the file must match the name
of the public class. For example, a class declared as public class Dog { }
must be in a source code file named Dog.java.
4. If the class is part of a package, the package statement must be the first line
in the source code file, before any import statements that may be present.
If there are import statements, they must go between the package statement
(if there is one) and the class declaration. If there isn't a package statement,
then the import statement(s) must be the first line(s) in the source code file.
If there are no package or import statements, the class declaration must be
the first line in the source code file.
5. import and package statements apply to all classes within a source code file.
In other words, there's no way to declare multiple classes in a file and have
them in different packages, or use different imports.
6. A file can have more than one nonpublic class.
7. Files with no public classes can have a name that does not match any of the
classes in the file.


Modifiers fall into two categories:
1. Access modifiers: public, protected, private.
2. Non-access modifiers (including strictfp, final, and abstract).

strictfp :

strictfp is a keyword and can be used to modify a class or a method, but never a
variable. Marking a class as strictfp means that any method code in the class will
conform to the IEEE 754 standard rules for floating points. Without that modifier,
floating points used in the methods might behave in a platform-dependent way.



কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন