SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.

Slides:



Advertisements
Similar presentations
Introduction to Programming Java Lab 1: My First Program 11 January JavaLab1.ppt Ping Brennan
Advertisements

C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
IT151: Introduction to Programming
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Chapter 1: Introduction
CMT Programming Software Applications
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Chapter 2 Classes and Methods I Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Chapter 2 How to Compile and Execute a Simple Program.
Chapter 3 Getting Started with C++
Comments are for people Header comments supply basic information about the artifact.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 2: Java Fundamentals
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
Introduction to programming in the Java programming language.
8/31: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
Documentation and Programming Style Appendix A © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Chapter 2 part #1 C++ Program Structure
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
Java methods Methods break down large problems into smaller ones Your program may call the same method many times saves writing and maintaining same code.
Creating a Java Application and Applet
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
© 2007 Lawrenceville Press Slide 1 Chapter 3 Classes and Objects 1. How is a class different from an object?
CSC 110 – Intro to Computing - Programming
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
1/16: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
STRUCTURED PROGRAMMING Complete C++ Program. Content 2  Main Function  Preprocessor directives  User comments  Escape characters  cout statement.
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Topic Pre-processor cout To output a message.
Chapter 1.2 Introduction to C++ Programming
CSC201: Computer Programming
Chapter 3 GC 101 Java Fundamentals.
Yanal Alahmad Java Workshop Yanal Alahmad
Chapter 2, Part I Introduction to C Programming
Chapter 2 part #1 C++ Program Structure
Intro to Java.
Java Intro.
Introduction to C++ Programming
Chapter 3 – Introduction to C# Programming
Anatomy of a Java Program
Chapter 2: Introduction to C++.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Computer Programming-1 CSC 111
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program

Code Listing: Parts of a Java Program Reminder: The names of Java source files end with.java Closer examination of program, line by line : 1.// marks the beginning of a comment, the compiler ignores everything from the double slashes to the end of the line. Purpose is to document the code 2 Chapter 2: Parts of a Program

Code Listing: Parts of a Java Program Line 2: Blank – Known as “white space,” to make the program easier to read Line 3: class header (click to read more) 3 Chapter 2: Parts of a Program Marks beginning of a “class definition” public is an access specifier class is written in all lower case, Java keyword, beginning of a class definition Simple – name of the class, usually in Book title - upper case (user defined)

Code Listing: Parts of a Java Program Line 4. The Left brace is like the left cover of a book, it is the beginning of the class definition 4 Chapter 2: Parts of a Program Left brace – open brace

Code Listing: Parts of a Java Program Line 5: A method header A group of one or more programming statements that has a name. public static void main(String[] args) 1. public - methods are public or private, public ones are available from outside the class 2. static - all lower-case 3. void – methods can be used to return a value, if it does NOT return a value it is void 4. main – all lower case, every Java application has to have a least one main, but it can call other classes and instantiate objects from classes known to the project (see import) 5. Parameters 5 Chapter 2: Parts of a Program every Java application has to have one main,

Code Listing: Parts of a Java Program Line 6: Another left brace, but this marks the beginning of the method body 6 Chapter 2: Parts of a Program

Code Listing: Parts of a Java Program Line 7 Java statement, ends with a semicolon System – group of classes out – output class println – method that prints (outputs) a line of output and advances the cursor to the next line down String literal – all the characters within the quotation marks, put into the output “stream” just as it appears. Line 8: a closing or right brace, ends the main method 7 Chapter 2: Parts of a Program

Code Listing: Parts of a Java Program Line 9: closes the class 8 Chapter 2: Parts of a Program

Code Listing: Parts of a Java Program Summary of Simple program, Comments (remarks in Visual Basic) do not end with a semicolon, they are ignored by the compiler. Class headers and method headers do not end with a semicolon Use left and right braces to begin or end a class or method definition. 9 Chapter 2: Parts of a Program

Review Chapter 2: Parts of a Program 10 Java is case sensitive All Java programs must be stored in a file with a name that ends with the.java extension Comments are ignored A.java file can have many classes but only one public class Every Java application must have a method called main For every left brace there must be a right Statements end with semicolon