Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Lesson1-Introduction To Java

java

Uploaded by

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

Lesson1-Introduction To Java

java

Uploaded by

2106279
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

• OBJECT ORIENTED PROGRAMMING WITH JAVA

Course content
• Introduction to Java
• Java Basics
• Expressions
• Arrays
• Control Flow
• Classes
• Inheritance
• Polymorphism
• Binding
• Abstract Classes
• Graphical User Interface
References
• The textbook is Deitel & Deitel, Java How to Program (late
objects), 10th Edition, Prentice Hall (2014).
• Web Resources
Course Rationale

• This course is designed to teach Object-Oriented programming


concepts, techniques, and applications using the Java
programming language.
Course Objective
• Java language basics including variables, operators and
program control.
• Principles of object oriented programming in Java with classes,
inheritance, polymorphism,
Introduction to Java
• Java was conceived to develop advanced software for a wide
variety of network devices and systems.
• It has proven suitable for developing secure, distributed,
network-based end-user applications in environments ranging
from network embedded devices to the World-Wide Web and
the desktop.
X-tics of Java
• Simple: The fundamentals are learned quickly;
• Familiar: Java looks like a familiar language C++, but removes some
of the complexities of C++
• Object oriented: it treats almost everything under the sun a objects
• Portable: Java is designed to support applications capable of
executing on a variety of hardware architectures and operating
systems.
• Multithreaded: for applications with many concurrent threads of
activity.
• Interpreted: for maximum portability and dynamic capabilities.
• Secure: Sophisticated security features have been designed into the
language and run-time system.
Creating a Java Program
• The standard way of producing and executing a program is:
• Edit the program with a text editor; save the text with an
appropriate name.
• Compile: check syntax errors
• Execute (run): the program
Types of Java Programs
• There are two classes of Java programs
• Java stand-alone applications: they are like any other application
written in a high level language
• Java applets: they are special purpose applications specifically
designed to be remotely downloaded and run in a client machine.
They must be downloaded in a web browser
Components of a Java program -
Comments
1. Comments
• The program starts with a comment:
• // written GF 8/1/99
• // there is more than one way
• // to write a program
• all the characters after the symbols // up to the end of the line are
ignored;
• they do not change the way the program runs, but they can be very
useful in making the program easier to understand;
• they should be used to clarify some part of a program, to explain
what a program does and how it does it.
Comments
• Inline comments
• All text until end of line is ignored e.g.

• Multi-line comments
• All text between start and end of comment is ignored e.g.
/* comment goes
in this space, here */

• Javadoc comments
• Delimited by /** and */.
• Enable you to embed program documentation directly in your programs.
• The javadoc utility program reads Javadoc comments and uses them to
prepare program documentation in HTML format.

/** documentation */
2. A class definition:
• A class definition: Java programs include at least a class
definition such as public class HelloWorld. The class extends
from the first opening curly brace { to the last closing curly
brace }
3. The main() method:
• The main() method: a method is a collection of
programming statements that have been given a name
and that execute when called to run. Methods are also
delimited by curly braces
• all Java applications (not applets) must have a class (only
one) with a main() method where execution begins;
• the main() method is preceded by the words public
static void called modifiers;
• the main() method always has a list of command line
arguments that are passed to the program main(String[]
args) (which we are going to ignore for now)
RECUP
4. Statements
• Statements are
• instructions to the computer to determines what to do
• end with a semicolon ';'
• In this example there is only one statement
System.out.println("Hello world"); to print a
message and move the cursor to the next line
Reserved words
• class, static, public, void have all been reserved by the
designers and they can't be used with any other meaning
Case sensitive
• Java compilers are case sensitive, meaning that they see lower
case and upper case differently.
Programming Errors
• Programming errors can be divided into:
• Compilation errors: are detected by the compiler at
compilation time. The executable is not created.
• Execution errors: appear when the program runs.
Typically execution stops when an exception such as
this happens, it is possible to handle these errors
• Logical errors: the program compiles and runs with no
problems but gives out wrong results
• END

You might also like