December 3, 2017 admin

Identifiers: All the words that we will use in c are keywords or identifiers. keywords are predefined and can’t be changed by the users, While identifiers are used to give names to entities likes variables, arrays, functions and etc. There are some rules naming identifiers as: The name should consist of only alphabets (upper case and lower case), digits and underscore sign ( _ ). First character of identifier should be an alphabets or underscore. Name should not be a keyword. because c is case sensitive language, so upper case and lower case letter are considered different. for example code…

September 24, 2017 admin

Why constructor is needed? It can be a slow process to initialize all variables of a class, each time when an object is created.  Because the requirement of initialization is very common, JAVA allows objects to initialize themselves when they are created. This automatic initialization is performed through the use of constructor.   What is constructor? A constructor initializes an object immediately upon creation and it has the same name as class in which it resides. It is syntactically similar to a method. But it has no return type, not even void. This is because the implicit return type of…

August 9, 2017 admin

Classes are blueprint of any real entity in Java. A class contains of two types of members; a data or variable and another is method or function. Variable defined within a class are called as instance variables because each instance of the class (object of class) contains its own copy of these variables. Thus data of one object doesn’t affect the others. The General form of a class: class <name of class>{ // variables <data type> <instance variable1>; <data type> <instance variable2>;                 //methods                 <data type> <method name1(parameters)>{ //body of the method } <data type> <method name2(parameters)>{ //body of…

June 16, 2017 admin

An array is a group of similar-typed variable that are referred by a common name. A specific element in an array is accessed by its index. An array may have one or more dimensions. One Dimensional Arrays: The general form of a one dimensional array declaration is as: type variable-name[]; Note: Here type declares the base type of array like as int , char, boolean etc.     For example:  int month_days[]; Although this declaration establishes the fact that month_days is an array variable, no array actually exists. And value of the month_days is set to NULL, which represents an array…

June 3, 2017 admin 1Comment

There are two types of conversion in Java as: Implicit conversion Explicit conversion Implicit Conversion: Implicit conversion is also known as automatic conversion. When one type of data is assigned to different type of variable then automatic type conversion will take place if the following conditions are met. both type (source and destination) are compatible. The destination type is larger than the source type. when these two conditions are met, a widening conversion take place. For Example: byte a=100; int num=a; // a int value is large enough to hold all byte values. Note: when a large data type hold…

May 21, 2017 admin

The Primitive Type: There are eight primitive types of data : byte, short, int, long, char, float, double and boolean.  These can be put in four categories as: Integers : This group includes bytes, short, int and long , all of these are used for whole valued signed integer. Floating point numbers : This group includes float and double which represent numbers with fractional numbers. Characters : This group includes char, which represents data in a character set (‘ ‘) like letters and numbers. Boolean : This includes only boolean, it stores only true or false values. Integers : There…

May 13, 2017 admin 7Comment

There are mainly three categories of control statement in Java as: Selection Statement Iteration Statement Jump statement   Selection Statement : There are two selection statements that Java supports: if statement: It is conditional branch statement. It can be used to route program execution through two different paths. Syntax:  if(condition) { statement; } else{ statement; }      Note: condition is any expression that returns boolean value. if statement works like as: If the condition is true the statement inside the if block is executed. Otherwise else block statement is executed. There is no case when both block will be…

April 25, 2017 admin

class  Example { //program begins here. public static void main(String args[]){ System.out.println(“Hi, This is my first Java program.”); } } This is a simple program to print a line “Hi, This is my first Java program.” There are some key points that should be known to you: Here ‘class’ is a keyword that is used for creating new class and first letter of every class name should be capital. The Entire class definition, including all of its members will be defined in between of  opening curly braces ({) and closing curly braces (}). // is used for a single line…

April 20, 2017 admin

Object oriented programming (OOPs) is based on concept of “Objects”. Object : Object is real entity of class, or we can say it instance of class. object is collection of attributes and behavior. For example, a dog is an object and its attributes are like as color, name, breed and wagging the tail, barking, eating are the behavior of dog. There are three mechanism of OOPs concept, that help us to implement the OOPs model. Encapsulation Polymorphism Inheritance Encapsulation : Encapsulation means wrapping. And as it name says, it wraps the data (variables) and the code (Methods) in Java. It prevents…