In-class exercise 1. 1.downloading Java Java SE Java SE (JDK) 6 JDK 6u2 jdk-6u2-windows-i568-p.exe.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Using Java without BlueJ BlueJ projects A BlueJ project is stored in a directory on disk. A BlueJ package is stored in several different files.
Chapter 8: Interfaces and inner classes ● We learnt a number of mechanisms to abstract concepts and reuse them: – Data abstraction (Encapsulation and Information.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
TÉCNICAS DE PROGRAMACIÓN Lenguaje Java Java – 3 Daniel Finol.
Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
Jan Object Oriented Programming Yangjun Chen Dept. Business Computing University of Winnipeg.
Java Programming (Chapter 1). Java Programming Classes, Types, and Objects.
Java Programming Working with TextPad. Using TextPad to Work with Java This text editor is designed for working with Java You can download a trial version.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Introduction to Java ISYS 350. A Brief History Sun Microsystems released this language in 1996 – Versions: 1.0 – 1.6 Java Development Kit, JDK – Standard.
Using Java without BlueJ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling BlueJ projects A BlueJ.
Data Structures and Algorithm Design (Review). Java basics Object-oriented design Stacks, queues, and deques Vectors, lists and sequences Trees and binary.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Object-Oriented Design Running Time Recursion - Ed. 2 and 3.: Chapter 2, 3 - Ed. 4: Chapter 2, 3, 4.
Using Java without BlueJ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling BlueJ projects A BlueJ.
Unit2: Object-oriented programming Getting started with Java Jin Sa.
Tutorial 1 Introduction to Java Programming Bo Chen Department of Computer Science.
Using Java without BlueJ
Introduction to Java.
SEEM3460 Tutorial Java Programming in Unix. Code Translation Java source code Java bytecode Java compiler Bytecode interpreter machine code for target.
Introduction to the JDK Java for Computational Finance
public static void main (String[] args)
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
Tutorial 1. Q1: Compare and contrast between multiprocessors and multicore Multicore – Dual-core processor has two cores (e.g. AMD Phenom II X2, Intel.
Введение в JAVA. Java Java – язык программирования: объектно-ориентированный кроссплатформенный строго-типизированный.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
POS 406 Java Technology And Beginning Java Code
8: Interfaces Interfaces “Multiple inheritance” in Java –Name collisions when combining interfaces Extending an interface with inheritance Grouping constants.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
Interfaces. –An interface describes a set of methods: no constructors no instance variables –The interface must be implemented by some class. 646 java.
Agenda For Feb PowerPoint Presentation (Introduction to Java Methods) 2.Finish Unit 2 exercises on page 13 (due by the end of the class today). 4.
Java: Review Sept. 2003Yangjun Chen Java Java basics Art of programming Object-oriented programming Applets and graphics Introduction.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
 Instructor: Dr. Jason Nichols –  Office Hours: – 9:30-10:30 M/W/F or by appointment – Business Building.
1 Creating Web Services Presented by Ashraf Memon Hands-on Ghulam Memon, Longjiang Ding.
CS 4244: Internet Programming Network Programming in Java 1.0.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
Methods.
Programming Fundamentals I Java Programming Spring 2009 XuanTung Hoang Lab 01.
Copyright 2008 by Pearson Education Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: self-check: #16-19.
Objects First With Java A Practical Introduction Using BlueJ Using Java without BlueJ 1.0.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Computer Science 209 Software Development Packages.
Using Java without BlueJ BlueJ projects A BlueJ project is stored in a directory on disk. A BlueJ package is stored in several different files.
Object Oriented Programming Lecture 2: BallWorld.
Introduction of Java Fikri Fadlillah, S.T.
7 Class documentation and libraries
Java Programming in Unix
Software Development Packages
Compiling and Running a Java Program
Interface.
Programming without BlueJ Week 12
Introduction to Java Dept. Business Computing University of Winnipeg
Command Line Arguments
L3. Necessary Java Programming Techniques
L3. Necessary Java Programming Techniques
Exercise 11.1 Write a code fragment that performs the same function as the statement below without using the crash method Toolbox.crash(amount < 0,
Functional interface.
class PrintOnetoTen { public static void main(String args[]) {
Building a program (Java libraries) - an example
Debugging Exercise 00 Try compiling the code samples.
Presentation transcript:

In-class exercise 1

1.downloading Java Java SE Java SE (JDK) 6 JDK 6u2 jdk-6u2-windows-i568-p.exe

2. Implementation of a java program import java.util.*; import java.lang.*; interface CanFight { void fight ( );} interface CanSwim { void swim ( );} interface CanFly {void fly ( );} class ActionCharacter { public void fight( ) { }} class Hero extends ActionCharacter implements CanFight, CanSwim, CanFly { public void fight ( ) {System.out.println(“Can fight!”);} public void swim ( ) {System.out.println(“Can swim!”); } public void fly ( ) {System.out.println(“Can fly!”);} }

public class Adventure { static void t(CanFight x) { x.fight();} static void u(CanSwim x) { x.swim();} static void v(CanFly x) { x.fly();} static void w(ActionCharacter x) { x.fight();} public static void main (String[ ] args) { Hero h = new Hero( ); t(h); //Treat it as a CanFight u(h); //Treat it as a CanSwim v(h); //Treat it as a CanFly w(h); //Treat it as an ActionCharacter }

To compile the Java program: RealJ BlueJ JCreator or NotePad use “Command Prompt” javac Adventure.java java Adventure