Introduction of JAVA

 Introduction 

Founder 

  • James Gosling - Sun Microsystems 
  • Co-founder – Vinod Khosla


 What is java?

A general-purpose object oriented language.

Write Once RunAnywhere(WORA).

• Designed for easy Web/Internet applications.

Execution of JAVA


JVM 

(Java Virtual Machine) is an abstract machine that enables your computer to run a Java program.

When you run the Java program, Java compiler first compiles your Java code to bytecode. Then, the JVM translates bytecode into native machine code.

Java Runtime Environment 

JRE (Java Runtime Environment) is a software package that provides Java class libraries, Java Virtual Machine (JVM), and other components that are required to run Java applications.

Java Developmulent Kit 

Jdk is a collection of classes, java compiler, and JVM interpreter. 

JDK (Java Development Kit) is a software development kit required to develop applications in Java. When you download JDK, JRE is also downloaded with it. In addition to JRE, JDK also contains a number of development tools (compilers, JavaDoc, Java Debugger, etc).

Characteristics of Java

  • Java is platform independent
  • Java is portable
  • Java is object-oriented
  • Java is dynamic
  • Java is secure
  • Java is robust
  • Java is multithread

 Comments

 Comments in a program are called inline documentation. They should be included to explain the purpose of the program and describe processing steps. They do not affect how a program works Java comments can take three forms:

// this comment runs to the end of the line

/* this comment runs to the terminating symbol, even across line breaks */

/** this is a javadoc comment */

Strings

 Java defines the String class to handle strings A String is a collection of characters treated as a single unit.

It is not an array of char variables.

Type Casting 

Assigning a value of one type to a variable of another type is known as Type Casting. 

Syntax: dataType variableName = (dataType) variableToConvert; 

Implicit Casting in Java / Widening

Explicit Casting in Java / Narrowing


Types of operators:
  •  Java language offers many types of operators. 
  • Arithmetic operators 
  • Assignment operators 
  • Relational operators 
  • Logical operators 
  • Bitwise operators
  •  Conditional operators (ternary operators)
  • Increment/decrement operators
  •  Special operators


Command-line argument 
The java command-line argument is an argument i.e. passed at the time of running the java program.

POP VS OOP


Basic Concepts Of JAVA

Objects 
Objects are the basic run-time entities in an object-oriented system. Object may represent a person, a place, a bank account, etc. Objects take up space in the memory and have an associated address like a structure in C.
syntax:
class  classname  object name;

Classes 

Classes are user-defined data types.  The entire set of data and code of an object can be made a user-defined data type with the help of a class.  Objects are variables of the type class. Once a class has been defined, we can create any number of objects belonging to that class.

Data Abstraction and Encapsulation
 o The wrapping up of data and functions into a single unit is known as encapsulation. 
o The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.
Since the classes use the concept of data abstraction, they are known as Abstracted Data Types (ADT).

Inheritance
 o Inheritance is the process by which objects of one class acquire the properties of objects of another class.




Polymorphism - (ability to take more than one form )
o An operation may exhibit different behaviours in different instances. 
o The behaviour depends upon the types of data used in the operation. 
o add( 3, 5) gives 8 
o Add(3,5,8)
 o add(“hello”, “-world”) gives “hello-world” 

Dynamic Binding
Dynamic binding ( late binding ) means that the code associated with a given procedure call is not known until the time of the call at run-time. 
It is associated with polymorphism and inheritance. 

Access Specifiers

Public Access: The public access modifier is the direct opposite of the private access modifier. A class, method or variable can be declared as public and it means that it is accessible from any class.

Default:A default class is accessible inside the package but it is not accessible from outside the package i.e. all the classes inside the package in which the default class is defined can access this class.

Private:The private access modifier is specified using the keyword private. The methods or data members declared as private are accessible only within the class in which they are declared. Any other class of the same package will not be able to access these members.

Protected:The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.

Methods:

A method is a block of code which only runs when it is called. You can pass data, known as parameters, into a method. Methods are used to perform certain actions, and they are also known as functions.

Constructor:

A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes. In Java, a constructor is a block of codes similar to the method.

method vs constructor



Array:

        Array is a collection of similar type of elements that have contiguous memory location.

        Types of Array in java

        Single Dimensional Array

        Multidimensional Array




Thanks for watching

Comments

popular post

Design And Analysis Of Algorithm