0% found this document useful (0 votes)
22 views

Lesson6 Java Programming

The document discusses object-oriented programming and stages in developing a computer program including defining the problem, designing a solution, writing the program, and compiling, debugging and testing. It also covers Java programming language basics like syntax, features, characteristics, variable rules and types, and comments.

Uploaded by

Art Guzman
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Lesson6 Java Programming

The document discusses object-oriented programming and stages in developing a computer program including defining the problem, designing a solution, writing the program, and compiling, debugging and testing. It also covers Java programming language basics like syntax, features, characteristics, variable rules and types, and comments.

Uploaded by

Art Guzman
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Object-Oriented

Programming
INTRODUCTION TO
PROGRAMMING USING
JAVA
STAGES IN DEVELOPING A COMPUTER PROGRAM

1.) Defining the problem

 Begins with recognizing the need for information

 To better understand and analyze the problem we must conduct a study to the nature of the
problem and we must be able to define what are the necessary outputs required of the
program.
2.)Designing a solution to the problem

 Breakdown the problem into several steps so that it is easier for us to solve the problem in smaller
pieces.

 Algorithm
 Flowcharting

3.)Writing the program

PROGRAM

- A list of instructions written in a programming language that a computer can execute so that the
machine acts in a predetermined way.
TYPES OF PROGRAMMING STATEMENTS

1. Comments - Are statements that have no effect on the program, they are inserted at the key points
in the program and serve as an internal documentation of the program.

2. Declarations - Define items used in the program.

3. Input/output statements - Transfer data to and from the primary storage for use by the program, as
well as to and from other I/O devices like the monitor and the keyboard.

System.out.println(); or

System.out.print(); or

System.out.printf();
4.) COMPILING, DEBUGGING AND TESTING THE PROGRAM

 COMPILER
 DEBUGGING
 TESTING
PROGRAMMING LANGUAGE

 An artificial language designed to communicate instructions to a machine, particularly a computer


 Software used to create another software
TYPES OF PROGRAMMING ERRORS

 SYNTAX ERRORS – Errors due to the fact that the syntax of the language is not respected
 SEMANTIC ERRORS – Errors due to an improper use of program statements
 LOGICAL ERRORS – Errors due to the fact that the specification is not respected
 RUNTIME ERRORS – Error that cannot be detected by the compiler
TYPES OF PROGRAMMING ERRORS
History of Java

 1991
 James Gosling
 Developed by Sun Microsystem Inc.
 Open source
FEATURES OF JAVA

1. A PLATFORM INDEPENDENT LANGUAGE

 a platform is a pre-existing environment in which a programs runs, obeying its constraints an


and making use of its facilities.
2. AN OBJECT-ORIENTED LANGUAGE

 - is a way of organizing programs as collection of objects , each of which represents an instance of


a class.
 - Makes software development much easier to design and implement
 It uses classes, methods and objects
 Java compiler > Java byte>Java Virtual Machine>machine code
CHARACTERISTICS OF JAVA

1. Java is simple
2. Java is object-oriented
3. Java is interpreted
4. Java is portable
5. Java is secure
Basic Syntax:

 Case Sensitivity - Java is case sensitive, which means identifier Hello and hello would have
different meaning in Java.

 Class Names - For all class names the first letter should be in Upper Case.

Example class FirstSample


Program File Name - Name of the program file should exactly match the class name.

Example: Assume 'FirstSample' is the class name.


Method Names

Example: public void main()

Example:

public static void main(String[] args) {


System.out.println(“Hello World!”);
}
Program File Name

Example: Assume 'FirstSample' is the class name.


class Hello_World {
/* This is my first java program.
*This will print 'Hello World' as the output */
public static void main(String []args) {
System.out.println("Hello World");
System.out.println();
System.out.println(“End of Program”);
}
} //End of code
Comments in Java

1. Multiple line comments

public class MyFirstJavaProgram{


/** This is my first java program.
** This will print 'Hello World' as the output
**This is an example of multi-line comments. **/

2. Single line comments

// This is an example of single line comment


Variable
RULES IN USING VARIABLES

 Variable names are case-sensitive


 Connecting punctuation character
 Length of variable name can be number
 Special characters are not allowed
 Digit at start is not allowed
 Variable name must not be a keyword or reserved word

CONSTANT VARIABLES

Double salary = 5670;

You might also like