Download presentation
Presentation is loading. Please wait.
1
01 Introduction1June 15 01 Introduction CE00858-1: Fundamental Programming Techniques
2
01 Introduction2June 15 Objectives In this session, we will: review the structure of the module introduce the Java programming language develop a simple Java application
3
01 Introduction3June 15 Introduction to module focus on developing applications using Java each week you are expected to attend 2 lectures – to receive new concepts about programming 2 tutorials – to practice the new concepts in Java weekly sessions: presented with new material opportunity to practise new skills ask for help with problems exercises to complete
4
01 Introduction4 Emphasis on learning your goal is to learn about programming our goal is to help you learn you have many resources to help achieve your goal lecturers – ask them many questions lecture materials – use them often tutorial exercises – aim to do them all Blackboard, books, and the Internet take time to learn 150 hours for this module 48 hours in class – lectures and tutorials 102 hours out of class finish the tutorial exercises each week; don’t get behind read books and web sites about Java June 15
5
01 Introduction5 Programming is a practical skill that is mastered by doing it, not just reading about it! June 15
6
01 Introduction6June 15 Assessment 100% coursework exercises build into portfolio your responsibility to: attempt as many exercises as possible include in your portfolio what is indicated in specification keep portfolio up-to-date 3 in-class tests using Blackboard questions about material presented in lectures questions about your portfolio you will need your electronic portfolio available
7
01 Introduction7 Your portfolio your portfolio will need to be on electronic media use the H: drive or a pen drive make sure you organise and index your work you will need to refer to it quickly and easily in the tests make sure you have a back-up tutorial worksheets indicate what to include do as many tutorial exercises as possible you will not know which exercises will feature in the in-class tests June 15
8
01 Introduction8June 15 Introduction to Java high level object oriented programming language designed to be: simple object oriented distributed robust secure architecture-neutral portable multithreaded
9
01 Introduction9 What is computer programming? writing solutions to problems in a language that the computer can understand and execute several stages: identify the problem understand the problem – analysis describe the solution - design write the solution in a programming language - coding evaluate the solution and improve it if necessary - testing June 15
10
01 Introduction10 Programming lifecycle Identify problem Understand the problem Describe the solution Program the solution Test the program June 15
11
01 Introduction11June 15 Program development stages Write / edit source code Compile source code into bytecode (computer understandable form) Run program (bytecode) javac java Hello.java Hello.class Results on screen syntax errors logic errors
12
01 Introduction12June 15 A Simple Java Application //output Hello World public class Hello { public static void main (String[] args) { System.out.println ("Hello World"); System.out.println ("Welcome to Java"); } Comment - ignored when program runs this line is always written like this output a message to console window class name
13
01 Introduction13June 15 Write source code program can be written using any simple editor can use Notepad, Wordpad source file must be saved with an extension of.java File name has the form:.java
14
01 Introduction14June 15 Source code structure the first line is a comment indicated by // comments are ignored when the program is executed all Java code must be in a class every class has: a header that names it a body enclosed by { } that defines what it does code must be saved in a file called Hello.java public class Hello { //all code must be placed inside the braces } Class header Class body
15
01 Introduction15June 15 The main method classes are made up of at least one method all Java applications have a main method automatically run when the program is executed contains statements to perform a task every method has: a header that names it a body enclosed by { } that defines what it does public static void main (String[] args) { //all code must be placed inside the braces } Method header Method body
16
01 Introduction16June 15 Program statements the main method contains statements each statement is terminated with ; System.out.println ("Hello World"); System.out.println ("Welcome to Java"); these statements are method calls to the println method which is found in the System.out class all method calls are followed by parameters enclosed by ( ) brackets must be included even if there are no parameters the println method has a string parameter which will be output strings are enclosed by "" Class body Semicolons
17
01 Introduction17June 15 Pitfalls - programming Java is case sensitive Hello and hello are not the same main and Main are also different every statement finishes with ; headers are not statements – so no ; program blocks are bracketed using { } method names are always followed by ( ) strings are enclosed by "" compilers are very fussy – you must be accurate
18
01 Introduction18June 15 Compiling a Java application Java source code is in a human-readable format compiler: checks that code is grammatically correct converts valid code into bytecode which can be executed by the computer if there are no errors produces a.class file if there are no errors Sun provide a compiler called javac invoked from the command prompt javac Hello.java any errors will be displayed in window no output means no errors
19
01 Introduction19June 15 Executing a Java application bytecode is executed using interpreter provided by Sun invoked from the command prompt java Hello
20
01 Introduction20June 15 Pitfalls – compiling and running file name must be same as class name in code with.java as the extension public class Hello filename Hello.java the extension must be specified when file is compiled: javac Hello.java the extension must NOT be specified when the class is interpreted java Hello Class name File name
21
01 Introduction21June 15 Summary In this session we have: covered the module assessment requirements looked at the structure of a Java application introduced the main method seen how to output strings to the screen written, compiled and executed a Java application In the next session we will: look at using data within our programs
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.