Skip to main content

Class 1 Java introduction

What is Java

Java is a programming language and a platform.

Java is a high level, robust, secured and object-oriented programming language.

Platform: Any hardware or software environment in which a program runs, is known as a platform. Since Java has its own run time environment (JRE) and API, it is called platform.

Features of Java

The Java Features given below are simple and easy to understand.

  1. Simple
  2. Object-Oriented
  3. Portable
  4. Platform independent
  5. Secured

Object-oriented

Java is Object-oriented programming language. Everything in Java is an object. Object-oriented means we organize our software as a combination of different types of objects that incorporates both data and behavior.

Basic concepts of Oops are:
  1. Object
  2. Class
  3. Inheritance
  4. Polymorphism
  5. Abstraction
  6. Encapsulation

Variable

Variable is name of reserved area allocated in memory. In other words, it is a name of memory location. It is a combination of "vary + able" that means its value can be changed.
Ex. int data=50;//Here data is variable 

Types of Variable

There are three types of variables in java:
  • local variable
  • instance variable
  • static variable

1) Local Variable

A variable declared inside the method is called local variable.

2) Instance Variable

A variable declared inside the class but outside the method, is called instance variable . It is not declared as static.

3) Static variable

A variable which is declared as static is called static variable. It cannot be local.

  1. class A{  
  2. int data=50;//instance variable  
  3. static int m=100;//static variable  
  4. void method(){  
  5. int n=90;//local variable  
  6. } }//end of class  

Data Types in Java

Data types represent the different values to be stored in the variable. In java, there are two types of data types:
  • Primitive data types
  • Non-primitive data types
datatype in java

Object in Java

An entity that has state and behavior is known as an object .

Class in Java

A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. It is a logical entity. It can't be physical.
A class in Java can contain:
  • fields
  • methods
  • constructors
  • blocks
  • nested class and interface
  1. class <class_name>{  
  2.     field;  
  3.     method;  
  4. }  

Method in Java

In java, a method is like function i.e. used to expose behavior of an object.

Advantage of Method

  • Code Reusability
  • Code Optimization

Java Keywords

The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names.
abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile

Java naming conventions for identifiers

1. Use CamelCase for most identifiers (classes, interfaces, variables, and methods).
2. Use an initial capital letter for classes and interfaces, and a lower case letter for variables and methods.
3. For named constants, use all capital letters separated by underscores.
4. Avoid using $ characters in identifiers.

Java Package

java package is a group of similar types of classes, interfaces and sub-packages.
Package in java can be categorized in two form, built-in package and user-defined package.


Comments

Popular posts from this blog

Eclipse New Maven Project: Could not resolve archetype

Close Eclipse Delete repository folder (you can find it in C:\Users{your user}.m2) Open Eclipse again. It will install maven repository automatically down v Open Window > Preferences Open Maven > Archetypes Click 'Add Remote Catalog' and add the following: Catalog File:  http://repo1.maven.org/maven2/archetype-catalog.xml Description: maven catalog

Configure Maven Project in to Jenkins and Run

As we all know, maven is a build / project management tool, based on the concept of a project object model (POM) which contains every information about your project. Maven allows a project to build using its project object model to manage builds, dependencies, releases and documentation which are all managed from the pom.xml file. Maven defines a standard way to build the projects, test, and deploy project artifacts. It provides a framework that enables easy reuse of common build logic for all projects following Maven's standards. We discussed  maven in detail  earlier here and hope you have  configured maven . First lets Create a simple maven project in Jenkins Step 1:-  Click New Items on the left menu ->Enter Project Name in “Item name” field -> Select Maven Project ->Click OK Step 2:-  Provide the job description Step 3:-  In Source Code Management, Jenkins supports CVS and Subversion out of the box, with built-in support for...