Last week we gone through Data Type, today we will discuss about constant and some programming rules.
Constant: A numeric or string value that does not change. Constant expressions combine constants and operators, but no variables, and evaluate to the same value every time. If you are storing a constant value of any type, like- n=10, a numeric constant and integer type or s=”Foxing the Fox”, a string constant.
In BASIC when you store a string constant you have to mention the variable with a dollar ($) sign, s$=”Foxing the Fox”, a string constant.
Numbers, a decimal point and a negative sign all can be stored in a numeric variable, for string values can consists alphabets, numbers and symbols. Where boolean could have TRUE and FALSE.
Constant always come in the right side of the equal sign and variable in left side.
A=10
B=20
A=B
Mathematically above statement wrong but in computer we are just telling that the B is a constant and value of A will replace by the value of B, but B remain unchanged. Therefore, A becomes 20 and B remains 20.
C++, Java and C# provide the ability to declare a variable whose value specified at compile time and cannot be change at runtime. Java uses the final field modifier to declare such a variable, while c++ and C# uses the const keyword.
Rules for different Programming languages
Every programming language having its own Syntax (Grammar), rules and guidelines. Like old days in BASIC (GW-Basic) we have to bind a program with line number for each statement and line number should be in ascending order
10 a=10
20 b=20
Further when Bill Gates gave us Qbasic, line numbers were optional but only to be given when one use transfer control to other statement than the next one. Same follows for FORTRAN too.
Let us move to ‘C’, it is a process oriented programming language, where main control remain inside main() function, confuesd?
void main()
{
Statement;
Statement;
Child_function();
Statement;
}
Where child_function() is a method or procedure where you can do certain routine and at the end you return to main() function to the next statement.
Enter the OOPs, relax life is more easy than before, if you understand it. Object-Oriented Programming (OOP): A system of programming that permits an abstract, modular typing hierarchy, and features polymorphism, inheritance, and encapsulation.
First, let us ask – What is abstract?
Abstraction : Identifying the distinguishing characteristics of a class or object without having to process all the information about the class or object. When you create a class — for example, a set of table navigation buttons — you can use it as a single entity instead of keeping track of the individual components and how they interact. Represent essential features of a system without getting involvement with the complexity of the entire system.
Let me clear above point, as if you are using a watch and using as single unit. You do not have to bother how and what makes it work.
Constant: A numeric or string value that does not change. Constant expressions combine constants and operators, but no variables, and evaluate to the same value every time. If you are storing a constant value of any type, like- n=10, a numeric constant and integer type or s=”Foxing the Fox”, a string constant.
In BASIC when you store a string constant you have to mention the variable with a dollar ($) sign, s$=”Foxing the Fox”, a string constant.
Numbers, a decimal point and a negative sign all can be stored in a numeric variable, for string values can consists alphabets, numbers and symbols. Where boolean could have TRUE and FALSE.
Constant always come in the right side of the equal sign and variable in left side.
A=10
B=20
A=B
Mathematically above statement wrong but in computer we are just telling that the B is a constant and value of A will replace by the value of B, but B remain unchanged. Therefore, A becomes 20 and B remains 20.
C++, Java and C# provide the ability to declare a variable whose value specified at compile time and cannot be change at runtime. Java uses the final field modifier to declare such a variable, while c++ and C# uses the const keyword.
Rules for different Programming languages
Every programming language having its own Syntax (Grammar), rules and guidelines. Like old days in BASIC (GW-Basic) we have to bind a program with line number for each statement and line number should be in ascending order
10 a=10
20 b=20
Further when Bill Gates gave us Qbasic, line numbers were optional but only to be given when one use transfer control to other statement than the next one. Same follows for FORTRAN too.
Let us move to ‘C’, it is a process oriented programming language, where main control remain inside main() function, confuesd?
void main()
{
Statement;
Statement;
Child_function();
Statement;
}
Where child_function() is a method or procedure where you can do certain routine and at the end you return to main() function to the next statement.
Enter the OOPs, relax life is more easy than before, if you understand it. Object-Oriented Programming (OOP): A system of programming that permits an abstract, modular typing hierarchy, and features polymorphism, inheritance, and encapsulation.
First, let us ask – What is abstract?
Abstraction : Identifying the distinguishing characteristics of a class or object without having to process all the information about the class or object. When you create a class — for example, a set of table navigation buttons — you can use it as a single entity instead of keeping track of the individual components and how they interact. Represent essential features of a system without getting involvement with the complexity of the entire system.
Let me clear above point, as if you are using a watch and using as single unit. You do not have to bother how and what makes it work.
Inheritance is where in some cases, a class will have "subclasses," more specialized versions of a class. Subclasses inherit attributes and behaviors from their parent (super) classes, and can introduce their own.
Encapsulation Conceals the exact details of how a particular class works from objects that use its code or send messages to it. Encapsulation is achieved by specifying which classes may use the members of an object. The result is that each object exposes to any class a certain interface — those members accessible to that class.
Polymorphism is an object-oriented programming term. The ability to have methods with the same name, but different content, for related classes. The procedure to use is determined at run time by the class of the object. Function overloading, constructor overload is one of the example.
What is an object? Object means an instance. An object is a software bundle of variables related methods. An object is a particular instance of a class. The set of values of the attributes of a particular object is called its state.
What is a class? class is a model that defines the variables and the methods that common to all objects of a certain kind. A class is an abstract type. A class defines the abstract characteristics of an object, including its attributes, fields or properties and also its behaviors or methods or features. For example, the class Dog would consist of quality shared by all dogs, for example breed, fur colour etc.
Syntax
public class mySpace()
{
//Global variable declaration
public static void main(String args[])
{
//Body of the program
}
}It is not easy to write about all programming languages, I just tried to write those are in demand. Next week coming with user defined function(UDF)/method.
!!!So, do not expect a blast as these functions are very boring, for time being Bonne journée.!!!