Programming #2 Java Basics - Copy (1) PDF
Document Details
![IssueFreeRadon6091](https://quizgecko.com/images/avatars/avatar-4.webp)
Uploaded by IssueFreeRadon6091
TU Dublin
Nevan Bermingham
Tags
Summary
This presentation provides a basic overview of Java programming concepts and other programming topics. It covers fundamental programming concepts like flowcharts, logical operators, and hexadecimal representations. It can be used as a quick introduction to programming concepts, or as a reference for students.
Full Transcript
INTERNATIONAL & ACCESS FOUNDATION PROGRAMMES COMPUTER SCIENCE SEMESTER II Part 2 Java Basics © Nevan Bermingham IMPORTANT! 1. Create your own notes - the in-class notes will not be enough on their own. 2. You will need to have a copy of...
INTERNATIONAL & ACCESS FOUNDATION PROGRAMMES COMPUTER SCIENCE SEMESTER II Part 2 Java Basics © Nevan Bermingham IMPORTANT! 1. Create your own notes - the in-class notes will not be enough on their own. 2. You will need to have a copy of the class notes with you for the lab work, so download your own copies 3. Download BlueJ. BlueJ is free. http://www.bluej.org/ 4. Ask Questions! This is VERY IMPORTANT. Java can be sometimes complicated and confusing – make sure you understand the What is a Programming Language? The definition of a Programming Language:- “An artificial language used to write instructions that can be translated into machine language and then executed by a computer.” What is a Programming Language? Java is one example of a Programming Language. A Program is a list of instructions, that tell the computer what to do. Programming Languages can be used to create programs that control the behaviour of a computer. A Program is created by using a Programming Language, and then it is compiled into an application. What is Java & Javascript? Java is a Programming Language. Java is a Programming Language that is used to make applications that work on any computer (For example Windows and Mac’s). Javascript is used to make applications from within a webpage, by the browser – this is sometimes called an “applet”. Why do we use Javascript? The problem with HTML is that its static:- Static means the website is the same every time. HTML is only for placement of Webpage Elements (for example: Images and Text) on Screen. Does not allow for Customisable Webpage that change to meet the User’s needs in real time. Java can Do things: A Clock on the Screen. A Moving Banner. A Game. Why do we use Java & Javascript? Its Simpler than most other languages. Java & Javascript are Platform Independent Languages– or to put in another way, Java Applications can be used on many different types of computers. Java was written to make it easier to use over a network – this makes it ideal for internet applications. Java is Secure – Security of the user and their data is essential for Internet Applications. Java is freely available. Why not use English? Look at this picture. What do you see here? Describe it. Why not use English? Description from Paul: “I see a collection of different buildings, some are blue and some are not. They all have windows. I like the Red one best.” Description from Mary: “I see a group of buildings with many different colours. They are of different heights, but one is the tallest. The Blue Building has a pointed roof” Why not use English? What are the other colours? Description from Paul: “I see a collection of different What type of buildings, some are blue and some window? are not. Not useful They all have windows. information. I like the Red one best.” How many Description from Mary: buildings? “I see a group of buildings with What height are many different colours. they? They are of different heights, but What does “tallest” one is the tallest. mean? The Blue Building has a pointed There are two Blue roof” Buildings. Why not use English? English Java Precise Imprecise Portable to Words Many Mean Platforms Different Fewer Too many Things Words Logical & Dialects Easier to and Learn than VariationsComputers Uses English Do Not Simple Speak English English Words What’s a Compiler? A Compiler Application BlueJ Operating System Compu Keyboar ter Interne d Hardw t Mouse are Screen What Does a Compiler Do? User Writes Java Code What Does a Compiler Do? BlueJ The User Compiler Writes Java Makes the Code Application What Does a Compiler Do? BlueJ This The Application User Compiler can be Writes Java Makes the “run” on Code Application other Computers Java Code is Compiled for an OS Java Code Compiler ByteCode Java Virtual Machine Operating System Hardware Storag Input Networ Memor e Output k y Where does Java fit in? © Filip Car-Čorko, G11 What are Java Libraries? The Java Class Library is a set of libraries that Java applications can Link call at run time. Reusable Functions Code Libraries Tasks such as network access and file access which are often heavily dependent on the platform used. Example Libraries: Input Output Mathematical Functions Graphics File Handling Networking Compiling Code A compiler is a computer program that transforms source code written in a programming language into another computer language, usually having a binary form known as object code (Java:- Bytecode) Links to libraries (e.g. standard Java Libraries for Input & Output) We will be using BLUEJ Free & Used by DIT Has basic Error Checking www.bluej.org Java Popularity Same Coding Family Why Java? Write Once, Run Popular You’ll be able to Anywhere with programme client- C, easily in server web C++, C#, application Javascript (Similar syntax) s Popular with Free & client- Open server web Source application s These are FLOWCHARTS... Start Test a Conditi0n? ACTION The Flow of the FALSE Programme TRUE ACTION USER INPUT or OUTPUT TRUE End Why use Flowcharts? Flowcharts are a pictorial or graphical representation of a process which makes them easy to read. Flowcharts are used in many industries including entertainment, engineering, physical sciences and computer programming => Industry Standard The purpose of all flow charts is to communicate how a program works or should work without any technical jargon or code. We will look at flowcharts later in the Why use Flowcharts? Being able to do Flowcharts well is important. They help you look at the logic of a problem. When the logic is right, the code is easy The Mathematics of Computing Boolean Logic - Boolean logic is used to test conditions in a computer programme Binary – The language of computing Hexadecimal – Used instead of Binary Boolean Logic Boolean algebra, as developed in 1854 by George Boole Boolean algebra is the algebra of truth values 0 and 1 0 and 1 can also be referred to as True(1) or False(0) Today, all our computers use Boole's logic system - using microchips that contain thousands of tiny electronic switches arranged into logical ‘gates’ The main ones you need to know are Logical Operators Look at this Chart to decide if we take an umbrella... Is it Raining Is the Forecast Take an Now? Bad? Umbrella... No No ? Yes No ? No Yes ? Yes Yes ? ‘OR’ Operator An Example of OR Is it Raining Is the Forecast Take an Now? Bad? Umbrella... No No No Yes No Yes OR No Yes Yes Yes Yes Yes ‘AND’ Operator An Example of AND Is it Raining Is the Forecast Take an Now? Bad? Umbrella... No No No Yes AN No No D No Yes No Yes Yes Yes NOT Expressions Normally used with “equals” For example: Mary is driving a car Mary cannot drive the car at a red light. Mary can drive at all other traffic light colours. So... IF Traffic Light NOT EQUAL Red => Mary can drive the car In other words, any colour other then red…. Binary Binary is how computer count 000000 000001 000010 000011 000100 000101 000110 000111 Hexadecimal So, humans use Hexadecimal instead of Binary Binary is to the Base 2 We normally count in Decimal (Base10) Hexadecimal is Base16 Hexadecimal (HEX) Counting in Hexadecimal, or Base16 001 0x001 011 0x00B 002 0x002 012 0x00C 003 0x003 013 0x00D 004 0x004 014 0x00E 005 0x005 015 0x00F 006 0x006 016 0x010 007 0x007 017 0x011 008 0x008 018 0x012 009 0x009 019 0x013 010 0x00A... Hexadecimal (HEX) & Binary HEX BIN 0 -> 0000 1 -> 0001 2 -> 0010 3 -> 0011 4 -> 0100 5 -> 0101 6 -> 0110 7 -> 0111 8 -> 1000 9 -> 1001 A -> 1010 B -> 1011 C -> 1100 D -> 1101 E -> 1110 F -> 1111 Hexadecimal (HEX) Bit is 1 or 0 (Binary) Byte is 8 bits 0000 0000 up to 1111 1111 in Binary In Hex it is 0x00 up to 0xFF In Decimal it is 00 up to 255 You can use calculators on the Internet that will convert these HEX in Java You will see HEX used in Java and other programs instead of Binary and Decimal (unless the computation is in decimal) An example of HEX in Java is to select colours: Red is 0xFF0000 Green is 0x00FF00 Do not be too worried about Hexadecimal, but be aware when you see the format in code. Terminology Review A Browser: A browser is an application that reads HTML files and displays the contents on the screen – examples are Firefox, Internet Explorer and Chrome. An Operating System: This is the software that runs the Computer – Windows 7 and OS X Lion A Compiler: This is an application that converts “code” into an application hat can be “run” on a computer. HTML: Hyper Text Mark Up Language - a standardized system for tagging text files to create font, colour, graphic, and hyperlink effects on World Wide Web pages. Further Reading Any of the Java for Dummies range of books are useful Websites: Java Made Easy http://www.java-made-easy.com/ index.html Java For Beginners http://www.homeandlearn.co.uk/java/