Tuesday, January 21, 2014

New To Java Programming? Here Are Some Fundamentals To Keep In Mind

The fundamentals of any programming language are core for acquiring an edge in the future. Hence mastering it may require time but it is best to start late than to end in a dead end. Java is one programming language, which needs a strong foundation and practice of the concepts.

As cited on udemy.com, here are some basic concepts that you should know if you want to be successful in Java or any other programming language-

Fundamentals, Programming, Language, Core, Variables, Operations, Classes and Objects, Fields, Methods, Constructors, Concepts




1. Variables – Most computer programs read data from one point, process the data, and then write the data at other place that include the computer monitor or a database file on the hard drive. In most programming languages, data is kept in variables of X and Y and a host of other variables. Once you start making Java programs, you must declare variables, assign values and execute operations with the use of the variables.

2. Operations – Just like a calculator, Java programs make use of operators (+, -, *, /, ?, etc) to work with the variables in your program. These can be used for assigning value to variables, performing mathematical functions, and creating new objects based on variables. Operators are utilized in conditional logic statements like for loops, while loops, if statements, switch statements, and method calls.

3. Classes & Objects - Classes are structured for grouping variables and operations together in coherent modules. They have fields, constructors and methods along with other attributes. Objects are specific instances of a class. An apt example to understand classes and objects is to relate it to cars as it has all possible cars within it. Since all cars have similar features like four wheels, an engine, a transmission, seatbelts, a steering wheel, etc. Once you have created an object, it is an example of a car and by default takes all of its attributes. This is called inheritance.

4. Fields – This is a variable belonging to a class or object. For example, the Car Class can define a field called brand. All Car objects will contain this brand field, but the field value can be different for each instance of the class. This permits Car objects to be distinct from each another with the same basic attributes inherent to all cars.

5. Constructors – This is a special type of method that is executed once an object has been created. Its sole aim is to assign values to the fields which are specific to that particular instance of the object. For example, if you are making a car object, you might need to tell the program the brand of your car, the colour, its speed, and direction.

6. Methods – This is a group of operations that carry out certain function together. Methods benefit from another object-oriented programming concept known as Encapsulation. For example, if there is a method for speeding up the car. The driver only knows that by pressing the gas pedal the car goes faster. He is not bothered about how the car moves faster. Encapsulation refers to the internal workings of a particular method which are hidden from the remainder of the program and other methods within the program. Methods are those that really perform the “work” in your programs.

No comments:

Post a Comment