Chapter 1 Introduction to Computers, Programs, and Java

Similar documents
Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Objectives. Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer?

Chapter 1 Introduction to Computers, Programs, and Java

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

CHAPTER 1 INTRODUCTION TO COMPUTERS, PROGRAMS, AND JAVA. Objectives

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000)

Chapter 1 Introduction to Computers, Programs, and Java

Introduction to Java. Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.

Chapter 1 Introduction to Java

Eng. Mohammed Alokshiya

Introduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Chapter 1: Introduction to Computers, Programs, and Java

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Programming: detailed instructions which tell the computer hardware what to do aka software Computer Science: the study NOT of computers, but of what

Eng. Mohammed S. Abdualal

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

Introduction to Java Programming

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

CHAPTER 1. Introduction to JAVA Programming

Lecture 1: Introduction to Java

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Module 1: Introduction to Computers, Programs, and Java

Programming. Syntax and Semantics

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

CompSci 125 Lecture 02

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

CHAPTER 1 Introduction to Computers and Java

Introduction to Java. Nihar Ranjan Roy.

Lesson 01 Introduction

II. Compiling and launching from Command-Line, IDE A simple JAVA program

History Introduction to Java Characteristics of Java Data types

AP Computer Science A: Java Programming

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Certified Core Java Developer VS-1036

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

Introduction to Java

Getting Started with Java. Atul Prakash

AP Computer Science A

Getting Started. Chapter 1. Java Programming FROM THE BEGINNING. Chapter 1: Getting Started

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

C++ Spring Break Packet 11 The Java Programming Language

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

Lecture 1: Overview of Java

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 1

Introduction to OOP Using Java Pearson Education, Inc. All rights reserved.

Fundamentals of Programming. By Budditha Hettige

Introduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language

Java Programming. Zheng-Liang Lu. Java 301 Summer Department of Computer Science & Information Engineering National Taiwan University

From High Level to Machine Code. Compilation Overview. Computer Programs

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

2 Introduction to Java. Introduction to Programming 1 1

1. What is Jav a? simple

COMP Computer Basics. Yi Hong May 13, 2015

CS 177 Recitation. Week 1 Intro to Java

The Computer System. Hardware = Physical Computer. Software = Computer Programs. People = End Users & Programmers. people

9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Chapter Goals. Contents INTRODUCTION

Introduction to JAVA Programming Language

Eclipse. JVM, main method and using Eclipse. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

CHAPTER INTRODUCTION. Final Draft Oct. 15, Slides by Donald W. Smith TechNeTrain.com. Copyright 2013 by John Wiley & Sons. All rights reserved.

Chapter Goals. Contents. 1.1 Computer Programs

COSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan

CSE 421 Course Overview and Introduction to Java

JVM interprets the Java bytecode, controls how it interacts with the operating system and manages memory.

Chapter 3: Operating-System Structures

Introduction to Programming (Java) 2/12

Introduction. Lecture 1 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz

1 Introduction Java, the beginning Java Virtual Machine A First Program BlueJ Raspberry Pi...

Java Programming. Zheng-Liang Lu. Java 304 Fall Department of Computer Science & Information Engineering National Taiwan University

Chapter 2: Programming Concepts

Introduction to Computers and Java

This lecture will take you through simple and practical approach while learning Java Programming language.

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

CS11 Java. Fall Lecture 1

Getting Started With Java

The Programming Process Summer 2010 Margaret Reid-Miller

Chapter 1. Introduction

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

Short Questions. Instructor: Created by: Visit: 2/2/2018 OOP with JAVA. Muhammad Naveed

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

What is Java Platform?

Computer Fundamentals

IT151: Introduction to Programming (java)

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Pace University. Fundamental Concepts of CS121 1

Transcription:

Chapter 1 Introduction to Computers, Programs, and Java 1.1 What are hardware and software? 1. A computer is an electronic device that stores and processes data. A computer includes both hardware and software. In general, hardware is the physical aspect of the computer that can be seen, and software is the invisible instructions that control the hardware and make it work. The hardware of a computer consists of a CPU, cache, memory, hard disk, floppy disk, monitor, printer, and communication devices. 1.2 List five major hardware components of a computer. 2. Five major hardware components: CPU, Memory, Storage Devices, Input/Out Devices, and Communication Devices. 1.3 What does the acronym CPU stand for? 3. CPU stands for Central Processing Unit. It is the brain of the computer. 1.4 What unit is used to measure CPU speed? 4. The unit of measurement of clock speed is the hertz (Hz), with 1 hertz equaling 1 pulse per second. The clock speed of a computer is usually stated in megahertz (MHz) (1 MHz is 1 million Hz). 1.5 What is a bit? What is a byte? 5. A bit is a binary digit 0 or 1. A byte is a sequence of 8 bits. 1.6 What is memory for? What does RAM stand for? Why is memory called RAM? 6. Memory is like a work area for programs. Before a program is executed, it is brought into the memory. RAM stands for random-access memory. It is called RAM because a memory cell can be accessed directly. Page 1

1.7 What unit is used to measure memory size? 7. Memory size is measured in bytes. 1.8 What unit is used to measure disk size? 8. Disk size is measured in bytes. 1.9 What is the primary difference between memory and a storage device? 9. Memory is volatile, because information is lost when the power is turned off. Programs and data are permanently stored on storage devices and are moved, when the computer actually uses them, to memory, which is much faster than storage devices. 1.10 What language does the CPU understand? 10. The machine language is a set of primitive instructions built into every computer. This is the language understood by a computer and executed by a computer. 1.11 What is an assembly language? 11. Assembly language is a low-level programming language in which a mnemonic is used to represent each of the machine language instructions. 1.12 What is an assembler? 12. Assembler is a software that translates assembly language into machine language. 1.13 What is a high-level programming language? 13. The high-level languages are English-like and easy to learn and program. 1.14 What is a source program? 14. The program written in a programming language is called a source program. Page 2

1.15 What is an interpreter? 15. An interpreter is a software that reads one statement from the source code, translates it to the machine code or virtual machine code, and then executes it right away 1.16 What is a compiler? 16. A compiler is a software that translates a program in high-level language into machine language code. 1.17 What is the difference between an interpreted language and a compiled language? 17. An interpreter reads one statement from the source code, and translates it to the machine code or virtual machine code, and then executes it right away. A compiler translates the entire source code into a machine code file, and the machine code file is then executed. 1.18 What is an operating system? List some popular operating systems. 18. The operating system (OS) is a program that manages and controls a computer s activities. The examples of OS are Windows 98, NT, 2000, XP, or ME. Windows. Application programs such as an Internet browser and a word processor run on top of an operating system. 1.19 What are the major responsibilities of an operating system? 19. Major responsibilities: a. Controlling and monitoring system activities b. Allocating and assigning system resources c. Scheduling operations Page 3

1.20 What are multiprogramming, multithreading, and multiprocessing? 20. Multiprogramming allows multiple programs to run simultaneously by sharing the CPU. Multithreading allows concurrency within a program, so that its subtasks can run at the same time. Multiprocessing, or parallel processing, uses two or more processors together to perform a task. 1.21 Who invented Java? Which company owns Java now? 21. Java was invented by a team led by James Gosling at Sun Microsystems in 1991. Originally called Oak, it became Java in 1995 when it was redesigned for developing Internet applications. Oracle bought Sun and Oracle now owns Java. 1.22 What is a Java applet? 22. Java applet is a special program that runs from a Web browser. 1.23 What programming language does Android use? 23. Android uses the Java programming language. 1.24 What is the Java language specification? 24. The Java language specification specifies the syntax for the Java language. 1.25 What does JDK stand for? 25. JDK stands for Java Development Toolkit. 1.26 What does IDE stand for? 26. IDE stands Integrated Development Environment. Page 4

1.27 Are tools like NetBeans and Eclipse different languages from Java, or are they dialects or extensions of Java? 27. NetBeans and Eclipse are not programming languages, nor dialects, nor extensions of Java. They are Java development tools. 1.28 What is a keyword? List some Java keywords. 28. Keywords have specific meaning to the compiler and cannot be used for other purposes in the program such as variables or method names. Examples of keywords are class, static, and void. 1.29 Is Java case sensitive? What is the case for Java keywords? 29. Java source code is case sensitive. Java keywords are always in lowercase. 1.30 What is a comment? Is the comment ignored by the compiler? How do you denote a comment line and a comment paragraph? 30. Comments are used to document what a program is for and how a program is constructed. Comments help the programmers or users to communicate and understand the program. Comments are not programming statements and are ignored by the compiler. In Java, comments are preceded by two forward slashes (//) in a line or enclosed between /* and */ in multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */. 1.31 What is the statement to display a string on the console? 31. System.out.println(string); Page 5

1.32 Show the output of the following code: public class Test { public static void main(string[] args) { System.out.println("3.5 * 4 / 2 2.5 is "); System.out.println(3.5 * 4 / 2 2.5); 32. Output is 3.5 * 4 / 2 2.5 is 4.5 1.33 What is the Java source filename extension, and what is the Java bytecode filename extension? 33. The source file extension is.java and the bytecode file extension is.class. 1.34 What are the input and output of a Java compiler? 34. The input of a Java compiler is a Java source code file and the output is a Java class file. 1.35 What is the command to compile a Java program? 35. javac is the JDK command to compile a program. 1.36 What is the command to run a Java program? 36. java is the JDK command to run a program. 1.37 What is the JVM? 37. JVM is the Java Virtual Machine that runs a Java program. Page 6

1.38 Can Java run on any machine? What is needed to run Java on a computer? 38. Java can run on any machine with a JVM. 1.39 If a NoClassDefFoundError occurs when you run a program, what is the cause of the error? 39. Java interpreter cannot find the.class file. Make sure you placed the.class in the right place, and invoked java command with appropriate package name. 1.40 If a NoSuchMethodError occurs when you run a program, what is the cause of the error? 40. The class does not have a main method, or the signature of the main method is incorrect. 1.41 What is the statement to display the message Hello world in a message dialog box? 41. JOptionPane.showMessageDialog(null, Hello world ); 1.42 Why does the System class not need to be imported? 42. The System class is in the java.lang package. This package is implicitly imported. So, there is no need to explicitly import it. 1.43 Are there any performance differences between the following two import statements? import javax.swing.joptionpane; import javax.swing.*; 43. No performance difference. Page 7

1.44 Reformat the following program according to the programming style and documentation guidelines. Use the end-of-line brace style. public class Test { // Main method public static void main(string[] args) { /** Display output */ System.out.println("Welcome to Java"); 44. Answer: public class Test { // Main method public static void main(string[] args) { /** Display outpput */ System.out.println("Welcome to Java"); 1.45 What are syntax errors (compile errors), runtime errors, and logic errors? 45. Syntax errors are detected by compilers. Runtime errors occur during execution of the program. Logic errors results in incorrect results. Page 8