Posts

Showing posts from December, 2015

Abstraction in Java

Abstraction Abstraction: Hiding of implementation and using the functionality is called as abstraction. Abstraction in java can be achieved by using a special classes called "Abstract classes". Abstract Classes: These are same as classes but have two types of methods namely : Concrete Methods  Abstract Methods 1.Concrete Methods : The method which have declaration along with the body/logic of the  method such Methods are called as Concrete Methods. Syntax: class ClassName {      <datatype> methodName()     {         Statements;      } } Example: class ConctreteClassName {     void concrete()    {        System.out.println("concrete Method");    } }  2.Abstract Method: The method which have no body or logic Such methods are called as Abstract Methods. Syntax: abstract class ClassName {    abstract ...

Strings In Java

Strings In Java String:  String is a collection of characters (OR) It can also be defined as a character array. String is a predefined class in java which contains methods variables . These are immutable in nature (Once an object is created cant be changed). Syntax: Initialization of String: String variable[]={'char1','char2','char3'.......}; String object="value"; Example: String st={'v','o','i','d'}; String obj="void"; Declaration of String: String can be declared in many ways as follows : String str[]; Example: String str[]; Predefined Methods In String Class  1. length():  It is used to return the length of a string . The return value of length method is an integer. Syntax: object.length(); 2. charAt(int position): It is used to return a character at a specified of position in the parameter. Position is a integer parameter which will be considered a...