Fundamentals of Programming

Slides:



Advertisements
Similar presentations
Introduction to programming in java. Input and output to screen with Java program Structure of Java programs Statements Conditional statements.
Advertisements

Chapter 1: Computer Systems
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
Your First Java Program: HelloWorld.java
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
The Java Programming Language
Excerpts from Introduction to Java Programming, 4E Author: Y. Daniel Liang (Copyright by Prentice Hall)
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
Outline Java program structure Basic program elements
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Chapter 1 Introduction. © 2004 Pearson Addison-Wesley. All rights reserved1-2 Outline Computer Processing Hardware Components Networks The Java Programming.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Introducing Java.
Chapter 1 Introduction.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Java: Chapter 1 Computer Systems Computer Programming II.
Hello World 2 What does all that mean?.
Java Language and SW Dev’t
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Introduction to programming in the Java programming language.
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
1 Problem Solving b The purpose of writing a program is to solve a problem b The general steps in problem solving are: Understand the problemUnderstand.
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
Java FilesOops - Mistake Java lingoSyntax
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
COP-3330: Object Oriented Programming Course Introduction May 14, 2012 Eng. Hector M Lugo-Cordero, MS.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Object Oriented Programming Idea Computer program may be seen as comprising a collection of objects Object Fundamental entity in a JAVA program Used to.
Introduction to Object Oriented
Computer Programming Your First Java Program: HelloWorld.java.
C++ First Steps.
Dept of Computer Science University of Maryland College Park
Programming what is C++
Working with Java.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Lecture 1 Introduction Richard Gesick.
GC101 Introduction to computer and program
Chapter 3 GC 101 Java Fundamentals.
Console Output, Variables, Literals, and Introduction to Type
Data types and variables
Computer Programming Methodology Introduction to Java
Intro to Java.
Chapter 1 Introduction to Computers, Programs, and Java
Hello World 2 What does all that mean?.
PROGRAM STRUCTURE CSC 111.
Chapter 1: Computer Systems
Focus of the Course Object-Oriented Software Development
CSE 142, Spring 2012 Building Java Programs Chapter 1
Chap 1. Getting Started Objectives
Instructor: Alexander Stoytchev
Presentation transcript:

Fundamentals of Programming Hello World

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.

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.

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.

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.

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.