Starting Out with Java - Java Slides PDF

Document Details

Uploaded by Deleted User

GIFT University

2020

Dr. Muhammad Faheem

Tags

java programming computer science programming languages software development

Summary

These are lecture slides on the Starting Out with Java From Control Structures through Objects topic, covering basic concepts of Java programming for an introductory computer science course given at GIFT UNIVERSITY in November 2020.

Full Transcript

Starting Out with Java From Control Structures through Objects Session 1 (Chapter 1): Introduction to Computers and Java Dr. Muhammad Faheem November 24, 2020 1 / 21 Introduction...

Starting Out with Java From Control Structures through Objects Session 1 (Chapter 1): Introduction to Computers and Java Dr. Muhammad Faheem November 24, 2020 1 / 21 Introduction By the availability of software (computer program), people use Internet to look for information and to communication each other. Without software, the computer is useless. Software is developed with programming languages (e.g., Java, Python, Visual Basic). Java is among the leading programming languages. 2 / 21 Why Java? Platform Independence Truly Object-Oriented Memory Management Multi-Threaded Secure and Simple Rich APIs (e.g. I/O, Networking, XML Parsing, Database Connection) 3 / 21 Where is Java Being Used? Building Anroid Apps (e.g. Anroid Studio, Google’s Anroid API) Java Web Applications (e.g. Gmail (backend), GIFT UIS) Software Tools and Frameworks (e.g. Eclipse, IntelliJ IDEA, Netbeans, MapReduce framework of Hadoop) Scientific Applications Games (e.g. Minecraft: Java Edition) 4 / 21 Programming Language Programming: Process of planning and creating a program. Programming Language: A set of rules, symbols, and special words. It is used to write computer programs. Computer Program: A set of instructions a computer follows in order to perform a task. Collectively, these instructions form an algorithm. Syntax Rules: Rules that specify which statements (instructions) are legal or illegal. Java is a case sensitive language. 5 / 21 Software System Programs: Operating systems (e.g. Windows, Mac, Linux) monitor the overall activity of the computer and provides services such as memory management, I/O activities, storage management. Application Programs: Word processors Spreadsheets Games 6 / 21 The Evolution of Programming Languages Machine language Assembly language High-level languages 7 / 21 Program Development Process 8 / 21 Program Development Process 9 / 21 Portability Portability: A program may be written on one type of computer and then run on a wide variety of computers, with little or no modification. 10 / 21 Compiler Program that translates source code into an executable form. While translating, compilers uncovers any syntax errors. Syntax Error: Mistakes that the programmer has made that violate the rules of the programming language. Sytax errors must be corrected before the compiler can translate the source code. Once the program sytactically correct, then compiler translate the source code into a file that contains byte code instructions. 11 / 21 Java Virtual Machine (JVM) Byte code instructions are not machine language, and therefore cannot be directly executed by the CPU. JVM (often called interpreter) is a program that reads Java byte code instructions and executes them as they are read. JVM simulates a computer whose machine language is Java byte code. 12 / 21 Common Language Elements Keywords Operators Punctuation Programmer-defined Identifiers Strict Syntactic Rules 13 / 21 Keywords Reserverd identifiers in Jave (e.g. public, static, class, void) used for their intended purpose. Written in lower case. Not allowed to be used as a programmer-defined indentifier. See table 1.3 from Book for list of Java keywords. 14 / 21 Operators Example: profit = sellingPrice - costPrice; = and − are operators. Performs operations on items of data known as operands. = is an assignment operator. 15 / 21 Punctuation Punctuations may be used for marking the beggining or ending of a statement or separating items in a list. Examples: ; ,. {} () [] Semi-colons are used to end Java statements. Part of learning Java is to learn where to properly use the punctuation. 16 / 21 Lines vs Statements Examples: System.out.println( message); This is one Java statement written using two lines. Line: A single line as it appears in the body of a program. Statement: Complete Java instruction that causes the computer to perform an action. Blank lines are only used to make program more readable. Statements can be a combination of keywords, operators, and programmer-defined names. 17 / 21 Programmer defined Identifiers (Variables) Data in a Java program is stored in memory. Variable is a named storage location in the computer’s memory. Variables are created by the programmer who assigns it a programmer-defined identifier. Examples: int hours = 40; 18 / 21 Syntax Rules that must be followed when writing a program. Syntax dictates how Java instructions must be written. Examples: How keywords and operators must be used. Where punctuation symbols must appear. 19 / 21 First Java Program See the Code Examples for Session 1! 20 / 21 Credit Tony Gaddis, Starting out with Java: From Control Structures through Objects, 6th Edition, Pearson 2016. 21 / 21

Use Quizgecko on...
Browser
Browser