Posts

Java Methods

A method is a function. A method name can be any name and identifying the return type is maditory. Ex:   1. public int max(){}       ↑ access modifier is not manditory.   2. void area(int length){} It's just like functions in C language.

Java Class

A class is like a blueprint, it contains different kinds of things such as variables,methods,constructors etc. Let's see how to declare a class. A class name should start from a capital letter.        Ex: class HelloWorld{} Accessibility of variables can be changed according to Access Modifiers . There are four types of access modifiers. Private - visible only within the class. Protected - visible to any other class in the same package. Public - visible to any class. Default - same as protected. Visible to any other class in the same package. (-) mark is used to denote private variables. (+) mark is used to denote public variables. Ex: -name:String        private String name; +mark:int       public int mark;

Programming with Java

Java is the second most used programming language in the world. Java is a object oriented programming language. Characteristics of java Object oriented language Platform independent. Strongly-typed language. Interpreted and compiled language. Automatic memory management. Every java program is run on the Java Virtual Machine(JVM). It is the foundation of java platform and it is responsible for executing the byte codes and for fundamental capabilities of java. About Java programs, it is very important to keep in mind the following points.  1. Case Sensitivity - Java is case sensitive, which means identifier Hello and hello would have different meaning in Java.  2. Class Names - For all class names the first letter should be in Upper Case.  If several words are used to form a name of the class, each inner word's first letter should be in Upper Case.  Example : class MyFirstJavaClass   3. Method Names - All method names should start with a Lower Case letter.

C - Pointers

Image
A pointer is a special type of variable which is used to store an address of an existing variable. Now let's see how to use a pointer. In the following example we have used a pointer to indirectly access a variable. A pointer can be called in two different ways. 1. Call by value 2. Call by reference Call by value In call by value, the copy of values of the variables are passed to the functions. In the following example copies of variables a and b are assigned to the variables x and y in the function swap. The values does not change here.Because they are just variables not pointers.We can't swap the values of variables as above. Call by Reference In call by reference, the memory addresses are assigned to the pointers.Therefore it will permanently change the value after a function call. In here values are changed because there are no variables but pointers.We can change the values of pointers simply as above. In here I have given you a brie

C - Functions

Image
C language is a function oriented programming language. When you develop a program ,you can create your own function or you can use existing functions. The main advantage of using a function is re usability. How to use existing functions main() is also a inbuilt function. There are some math library functions are included in C. Let's see how can we use such a function from a example. Output In the above code i have called the math.h library function inorder to call a inbuild math library function. It is the only alternation i have done to this code rather than the examples i have done before. Also by giving as '%.2f ' I have given a limit to display the float value. If i haven't given a limit,the float value will display fully as you can see below. And we should call the function to find the output of the input variable 'v '. Function calling is done at the last printf statement as sqrt(v). The syntax of declaring a function.

C - Arrays

Image
An array is a data structure which can be used to store set of values with similar data types. In C , arrays can be devided into two types. Single Dimensional Arrays Multi Dimensional Arrays Single Dimensional Arrays The declaration form of single dimensional array is, data_type array_name[size]; Ex: int number[5]; float number[5]; In a array index is starting from 0. Therefore the last index is always equals to (size - 1) In the above examples the size is defined to 5 therefore the last index is 4. We can assign values to relative indexes as below. number[0]=10; number[1]=4; number[2]=5; number[3]=47; number[4]=43; Also we can ask users to input numbers for the array and we can display the entered numbers. Let's see how that can happen from a example. Output of the above code.   Multi Dimensional Arrays In multi dimensional arrays, we can find different number of rows and columns. In below I have  explained how to declare a 3 x 4 m

C- Control Structures

A control structure defines the execution order of the given program statements. There are three types of control structures. Sequence (Linear) Selection Repetition (Iteration) Selection Structure In C language we can use the If and Switch statements to represent the selection structure. If statement also come in two ways. 1. if(condition){      statement;    }    else{     statement;    } 2. if(condition){      statement;    }    else if{     statement;    }    else{     statement;    } This second way is called as nested if statement. and also there can be only a if condition in a program. ex:  1. #include <stdio.h> #include <stdlib.h> int main() {     int no1,no2;     printf("enter two numbers");     scanf("%d %d",&no1,&no2);     if(no1>no2){         printf("highest is %d \n",no1);     }     else{         printf("highest is %d \n",no2