Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Programming

Similar presentations


Presentation on theme: "Fundamentals of Programming"— Presentation transcript:

1 Fundamentals of Programming
Hello World

2 Purpose of Programming
Write a program to solve a problem Problem solving steps: Understand the problem Break the problem into manageable pieces Design a solution Consider alternatives to the solution and refine the solution Implement the solution Test the solution & fix any problems The purpose of writing a program is to solve a problem. A program is written in a particular programming language that uses specific words and symbols to express the problem solution. A programming language defines a set of rules that determine exactly how a programmer can combine the words and symbols of the language into programming statements, which are the instructions that are carried out when the program is executed. The first solution we design to solve a problem may not be the best one.

3 Object-Oriented Programming
An object-oriented language is a programming model that uses classes and objects Objects are the basic pieces that make up a program Object-oriented programming is an approach to programming that uses the concept of classes and objects. It’s a brilliant approach since we live in an object-oriented world. Everywhere you look, there are objects. These objects have attributes that make them different from other objects. Many of these objects can perform some kind of action, or you can get information from them. In OOP, classes define how an object will be constructed. Then, objects are created from these classes, and you manipulate them in your program.

4 Java source code is translated into bytecode by the compiler
Java is a general-purpose, object-oriented computer programming language Java source code is translated into bytecode by the compiler Java has thousands of built-in classes that all Java programmers can use Java was initiated in 1991 by James Gosling at Sun Microsystems as one of his many set-top box projects. The language initially was called Oak, the Green, and ultimately Java. Java was introduced to the public in 1995 and has gained tremendous popularity since.

5 Hello World HelloWorld is generally the first application that everyone writes when first learning to program. All Java applications have a similar basic structure. Despite its small size and simple purpose, this program contains several important features. The first few lines of the program are comments, which start with the /** symbols and continue to the end of the line. Comments doesn't affect what the program does but are included to help someone reading the code understand what the program does. Programmers should include comments throughout a program to clearly identify the purpose of the program and describe any special processing. The rest of the program is a class definition. This class is called HelloWorld though we could have named it just about anything we wished. The class definition runs from the first opening brace to the final closing brace on the last line of the program. All Java programs are defined using class definitions. Below the class name is the main method. A method is a group of programming statements that are given a name. In this case, the name of the method is main and it contains only 1 programming statement. Like a class definition, a method is also enclosed in braces.

6 Main Method All Java applications have a main method, which is where processing begins. Each programming statement in the main method is executed, one at a time in order, until the end of the method is reached. Then the program ends, or terminates. The main method definition in a Java program is always preceded by the words, public, state, and void, which will be explained later. The use of String and args does not come into play in this particular program but will also be described later. The two lines of code in the main method invoke another method called println. We invoke or call a method when we want it to execute. The println method prints the specified character to the screen. The characters to be printed as represented as a character string, enclosed in double quote characters. When the program is executed, it calls the println method to print the statement. The code executed when the println method is invoked is not defined in this program. The println method is part of the System.out object which will be explored later.


Download ppt "Fundamentals of Programming"

Similar presentations


Ads by Google