Posts

Variables in Java - tutorial

Image
VARIABLES IN JAVA  Table of Contents Variable Comments Passing arguments to a program Rules for variable naming Casting Escape sequence characters Literals      Scope of the variable   What is a variable? A variable is a small memory location, where we can store a small amount of data. It can be any data type. Datatype can be alphabetical, numerical,  alphanumerical… etc. ex:   int   a;   int   →  is an integer datatype, it can  store only numbers.   a   →  is a variable name         ex:   int a,b,c; // variables declration     c = 0 ;      // initialization a = 5 ; b = 10 ;     To display the value of the variable use the following statement. System. out . println (a);           // 5 System. out . println ( "a=" + a); // o/p is a= 5     Comments: we write our own comments in program. They ...

Inheritance in Java

Image
  Corejava InheritanceNotes              Table of contents Inheritance Interfaces Super keyword   Abstract class Concrete class Overriding Dynamic binding vs Static binding           Inheritance in Java   Definiation :   Inheritance is one of the key features of Object-oriented programming. It is the mechanism in java which allows us to create a new class (derived class) from an existing class (base class).  Java supports different types of inheritance. The main types of inheritance those Java supports are as follows: Single Inheritance Multilevel Inheritance Hierarchical Inheritance: Multiple Inheritance (using Interfaces)   1. Single Inheritance: Derived class inherits the features (attributes and methods) from the base class and can have additional features of its own. The keyword extends used to inherit from one class to other.       Creating Inheritance in Java The genera...