Wednesday, 25 January 2017

Java |Java Constructures|Exception Handling In Java|Array|JVM|Java bytecode|Why Choose Java? Java was designed with a few key principles in mind:


Java
Java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable.
Java Constructures
  Constructors are required to create objects for a class. Constructors are used to initialize the instance variables of an object.
  Constructor declaration looks like method declaration. It must have the same name as that of the class and have no return type.
  Constructors can be classified into two types, default constructors and parametarized constructors.
  If you don't define a constructor, then the compiler creates a default constructor. Default constructors do not contain any parameters. Default constructors are created only if there are no constructors defined by us.
  Prametarized constructors are required to pass parameters on creation of objects. We can overload constructors with different datatypes as its parameters.
  Use 'this()' to communicate from one constructor to another constructor in the same class.

Exception Handling In Java
  • In exception is an event, which occurs during the execution of a program, that interrupts the normal flow of the program. It is an error thrown by a class or method reporting an error in code.
  • The 'Throwable' class is the superclass of all errors and exceptions in the Java language
  • Exceptions are broadly classified as 'checked exceptions' and 'unchecked exceptions'. All RuntimeExceptions and Errors are unchecked exceptions. Rest of the exceptions are called checked exceptions. Checked exceptions should be handled in the code to avoid compile time errors.
  • Exceptions can be handled by using 'try-catch' block. Try block contains the code which is under observation for exceptions. The catch block contains the remedy for the exception. If any exception occurs in the try block then the control jumps to catch block.
  • If a method doesn't handle the exception, then it is mandatory to specify the exception type in the method signature using 'throws' clause.
  • We can explicitly throw an exception using 'throw' clause.

Array
  • An array is a group of same kind of variables and can be accessible by a common name.
  • In java arrays are objects.
  • Any element in the array can be accessed by its index.
  • Arrays can be one dimensional or multi-dimensional.
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.

Java bytecode
Java bytecode is the instruction set of the Java virtual machine. Each bytecode is composed of one, or in some cases two bytes that represent the instruction (opcode), along with zero or more bytes for passing parameters.

Why Choose Java?

Java was designed with a few key principles in mind:
·         Easy to Use: The fundamentals of Java came from a programming language called c++. Although c++ is a powerful language, it was felt to be too complex in its syntax, and inadequate for all of Java's requirements. Java built on, and improved the ideas of c++, to provide a programming language that was powerful and simple to use.

·         Reliability: Java needed to reduce the likelihood of fatal errors from programmer mistakes. With this in mind, object-oriented programming was introduced. Once data and its manipulation were packaged together in one place, it increased Java’s robustness.

·         Secure: As Java was originally targeting mobile devices that would be exchanging data over networks, it was built to include a high level of security. Java is probably the most secure programming language to date.

·         Platform Independent: Programs needed to work regardless of the machine they were being executed on. Java was written to be a portable language that doesn't care about the operating system or the hardware of the computer.


1 comment:

  1. I don't know much about Java, but I just found this amazing offer for a brand new erp software from a microsoft partner in uk. I think my company is perfectly ready for such a big makeover! :)

    ReplyDelete