copy.dept_change( CSE ); // Original Objects also changed

Size: px
Start display at page:

Download "copy.dept_change( CSE ); // Original Objects also changed"

Transcription

1 UNIT - III

2 Topics Covered The Object class Reflection Interfaces Object cloning Inner classes Proxies I/O Streams Graphics programming Frame Components Working with 2D shapes.

3 Object Clone

4 Object Cloning in Java: When a copy of a variable is made, the original and the copy objects have references to the same object. This means a change to either variable also affects the other. Student original = new Student(1001, CCET ); Student copy = original; // taking copy copy.dept_change( CSE ); // Original Objects also changed Original = Student Copy = In order to copy an old object into another new object which should not refer to the old object but the values has to copied to a new reference then use the clone method. The object cloning is a way to create exact copy of another object without affecting one another. Student copy = original.clone(); copy.dept_change( CSE ); //Original unchanged Original = Student Copy = Student

5 The java.lang.cloneable interface must be implemented by the class whose object clone we want to create. If we don't implement Cloneable interface, clone() method generatesclonenotsupportedexception. The clone() method is a protected method defined in the Object class. Syntax of the clone() method is as follows: Syntax: Why use clone() method? protected Object clone() throws CloneNotSupportedException The clone() method saves the extra processing task for creating the exact copy of an object. If we perform it by using the new keyword, it will take a lot of processing to be performed that is why we use object cloning. Advantage of Object cloning Less processing task. Types of Cloning: 1. Shallow Cloning Default Cloning method 2. Deep Cloning To do cloning a class must Implement the Cloneable interface, and Redefine the Clone method with the public access modifier.

6 1. Shallow Copy: Shallow Cloning means field-by-field copying. If each and every field is numbers or basic types then there is no problem. If the fields in turn are objects of another class, then field-by-field copying will make the original and copy objects to refer to the same sub-objects. Original = Student String name = values int Stdid = values Date DOB = values String Copy = Student String name = values int Stdid = values Date DOB = values Date

7 In shallow copy, a new object is created which contains the exact copy of the values in the original object. Shallow copy follows the bit-wise copy approach. In shallow copy if the field is a memory address, then the address is copied. Thus if the address is changed by one object, the change gets reflected everywhere. Figure 1: The flow chart describes shallow copy In this figure, the object - mainobj1 has fields field1 of a primitive type say int, and an object of type String When we do a shallow copy of mainobj1, mainobj2 is created with field2 of type int which contains the copied value of field1 but the String object in mainobj2 - still points to objstr itself. Since field1 is a primitive data type, the value of it is copied into field2. But since objstr is an object, mainobj2 is pointing to the same address of objstr. So any changes made to objstr via mainobj1 get reflected in mainobj2.

8 Example 1 class Student implements Cloneable String name; Student(String n) name = n; public void setname(string s) name = s; public String getname() return name; public Object clone() try //shallow copy return super.clone(); catch(clonenotsupportedexception e) return null;

9 public class ShallowClone public static void main(string[] args) //Original Object Student original = new Student("Java Programming"); System.out.println("Original Object: " + original.getname()); //Clone Object Student cloned = (Student) original.clone(); System.out.println("Cloned Object: " + cloned.getname()); original.setname("advanced Java"); System.out.println("Original Object after it is updated: " + original.getname()); System.out.println("Cloned Object after updating original object: "+ cloned.getname()); Output: Original Object: Java Programming Cloned Object: Java Programming Original Object after it is updated: Advanced Java Cloned Object after updating original object: Advanced Java

10 Example 2 class Subject String name; String getname() return name; void setname(string s) name = s; Subject(String s) name = s; class Student implements Cloneable //Contained object Subject subj; String name; Student(String s, String sub) name = s; subj = new Subject(sub); String getname() return name; void setname(string s) name = s; Subject getsubj() return subj; public Object clone() //shallow copy try return super.clone(); catch (CloneNotSupportedException e) return null;

11 public class ShallowCopy public static void main(string[] args) //Original Object Student stud = new Student("John", "Algebra"); System.out.println("Original Object: " + stud.getname() + " - " + stud.getsubj().getname()); //Clone Object Student clonedstud = (Student)stud.clone(); System.out.println("Cloned Object: " + clonedstud.getname() + " - " + clonedstud.getsubj().getname()); stud.setname("dan"); stud.getsubj().setname("physics"); System.out.println("Original Object after it is updated: " + stud.getname() + " - " + stud.getsubj().getname()); System.out.println("Cloned Object after updating original object: " + clonedstud.getname() + " - " + clonedstud.getsubj().getname()); Output: Z:\Java Programs\Examples\Cloning>javac ShallowCopy.java Z:\Java Programs\Examples\Cloning>java ShallowCopy Original Object: John - Algebra Cloned Object: John - Algebra Original Object after it is updated: Dan - Physics Cloned Object after updating original object: John - Physics Z:\Java Programs\Examples\Cloning>

12 2. Deep Cloning: Cloning of Subclasses is called as Deep Cloning. In deep copy, not only all the fields of an object are copied, all the dynamically allocated memory address which are pointed by that object are also copied. When the copied object contains some other object its references are copied recursively in deep copy. It s typical restriction of the protected access. In this figure, the object mainobj1 has fields field1 a primitive data type say int, and an object of type String When we do a deep copy of mainobj1, mainobj2 is created with field2 containing the copied value of field1 and objstr2 is created which contains the copied value of objstr1 So any changes made to objstr1 in mainobj1 will not reflect in mainobj2.

13 Example 1 class Student implements Cloneable private String name; Student(String n) name = n; public String getname() return name; public void setname(string s) name = s; public Object clone() //Deep copy Student s = new Student(name); return s;

14 public class DeepClone public static void main(string[] args) //Original Object Student original = new Student("Java Programming"); System.out.println("Original Object: " + original.getname()); //Clone Object Student cloned = (Student)original.clone(); System.out.println("Cloned Object: " + cloned.getname()); original.setname("advanced Java"); System.out.println("Original Object after it is updated: "+ original.getname()); Output: System.out.println("Cloned Object after updating original object: "+ cloned.getname() ); Original Object: Java Programming Cloned Object: Java Programming Original Object after it is updated: Advanced Java Cloned Object after updating original object: Java Programming

15 Example 2 class Subject private String name; public String getname() return name; public void setname(string s) name = s; Subject(String s) name = s; class Student implements Cloneable //Contained object Subject subj; String name; Subject getsubj() return subj; String getname() return name; void setname(string s) name = s; Student(String s, String sub) name = s; public Object clone() subj = new Subject(sub); //Deep copy Student s = new Student(name, subj.getname()); return s;

16 public class DeepCopy public static void main(string[] args) //Original Object Student stud = new Student("John", "Maths"); System.out.println("Original Object: " + stud.getname() + " - " + stud.getsubj().getname()); //Clone Object Student clonedstud = (Student) stud.clone(); System.out.println("Cloned Object: " + clonedstud.getname() + " - " + clonedstud.getsubj().getname()); stud.setname("dan"); stud.getsubj().setname("physics"); System.out.println("Original Object after it is updated: " + stud.getname() + " - " + stud.getsubj().getname()); System.out.println("Cloned Object after updating original object: " + clonedstud.getname() + " - " + clonedstud.getsubj().getname()); Output: Z:\Java Programs\Examples\Cloning>java DeepCopy Original Object: John - Maths Cloned Object: John - Maths Original Object after it is updated: Dan - Physics Cloned Object after updating original object: John - Maths Z:\Java Programs\Examples\Cloning>

17 Inner Classes

18 Inner Classes: A class declared inside a class is known as inner class. Syntax of Inner class class Outer_class_Name class Nested_class_Name... There are three reasons to have an inner class: Inner classes represent a special type of relationship that is it can access all the members (data members and methods) of outer class including private. Inner classes are used to develop more readable and maintainable code because it logically group classes and interfaces in one place only. Code Optimization: It requires less code to write.

19 There are several Inner Classes. They are: Member Inner Class Anonymous Inner Class Local Inner Class Static Inner Class 1. Member Inner Class: A class that is declared inside a class but outside a method is known as member inner class. It is present common inside so that it can be accessed by all methods of the outer class. The Outer Class Object can have rights to access its members and the inner class members along with the inner class object. How to access Member Inner class From within the class From outside the class

20 Example 1 : within the class class Outer1 private int a=10; class Inner1 void msg() System.out.println( The value for a is "+data); void display() Inner1 in=new Inner1(); in.msg(); public static void main(string args[]) Outer1 obj=new Outer1(); obj.display(); Output: The value for a is 10

21 Example 2 : outside the class class Outer2 private int a=20; class Inner2 void msg() System.out.println("The value for a is " +a); class TestOuter2 public static void main(string args[]) Outer2 out=new Outer2(); Outer2.Inner2 in=out.new Inner2(); in.msg(); Output: The value for a is 20

22 Example 3 : class Inner3 int a; public void disp_inner() System.out.println("Inner Class Method"); class Outer3 Inner3 in = new Inner3(); int b; public void disp_outer() System.out.println("Outer Class Method");

23 class InnerOuter3 public static void main(string args[]) int c; Outer3 o = new Outer3(); o.b = 20; o.disp_outer(); o.in.a = 10; o.in.disp_inner(); c = o.b + o.in.a; System.out.println( The Value for c is : "+c); Output: Outer Class Method Inner Class Method The Value for c is : 30

24 2. Local Inner Class: A class that is created inside a method is known as local inner class. If you want to invoke the methods of local inner class, you must instantiate this class inside the method. Their scope is always restricted to the block in which they are declared. Local classes have a great advantage: they are completely hidden from the outside world not even other code in the Outer Class can access them. Local variable can't be private, public or protected. class Outer1 public void disp_outer() System.out.println("Outer Class Method"); class Inner1 void disp_inner() System.out.println("Inner Class Method"); Inner1 in = new Inner1(); in.disp_inner();

25 public static void main(string[] args) Outer1 out= new Outer1(); out.disp_outer(); Output: Outer Class Method Inner Class Method 3. Anonymous Inner Class: When using local inner classes, we can create any number of Objects for the Inner Class. If to make only a single object of a class, no need to give the class name. Such a class is called an Anonymous Inner Class. Here, Interface can be used, the inner class implements that interface. Outer Class s method define the implementation of the inner class within its own member function.

26 class Outer interface Interface public void disp_interface(); public void disp_outer() class Inner implements Interface public void disp_interface() System.out.println("Interface Method Invoked inside Inner Class"); Interface inter1 = new Inner();

27 Interface inter2 = new Interface() public void disp_interface() System.out.println("Interface Method in Object"); ; inter1.disp_interface(); inter2.disp_interface(); class AnonymousClass public static void main(string args[]) Outer o = new Outer(); o.disp_outer(); Output: Interface Method Invoked inside Inner Class Interface Method in Object

28 4. Static Inner Class: To hide the inner class inside another, but don t need the inner class to have a reference to the outer class object, static inner class can be used. The generation of that reference can be suppressed by declaring the inner class static. class Outer static class Inner class StaticInner Output: void display() public static void main(string[] args) System.out.println("Inner class reference is: " + this); Outer.Inner n = new Outer.Inner(); n.display(); Inner class reference is: Outer$Inner@19821f

29 Object Class: The Object class is the parent class of all the classes in java by default. In other words, it is the topmost class of java. The Object class is beneficial if you want to refer any object whose type you don't know. Notice that parent class reference variable can refer the child class object, know as upcasting. Let's take an example, there is getobject() method that returns an object but it can be of any type like Employee, Student etc., we can use Object class reference to refer that object. For example: Syntax: Object obj = new Student(); Object obj=getobject(); A variable of type Object is only useful as a generic holder for arbitrary values. Method public int hashcode() Description returns the hashcode number for this object. public boolean equals(object obj) compares the given object to this object. protected Object clone() throws CloneNotSupportedException public String tostring() protected void finalize()throws Throwable creates and returns the exact copy (clone) of this object. returns the string representation of this object. is invoked by the garbage collector before object is being garbage collected.

30 I/O STREAMS

31 I/O STREAMS The Java I/O means Java Input/Output. It is provided by the java.io package. This package has an InputStream and OutputStream. Java InputStream is defined for reading the stream, byte stream and array of byte stream. A Stream is a sequence of data. It is composed of bytes. It is basically a channel on which the data flow from sender to receiver. An input object that reads the stream of data from a file is called input stream and the output object that writes the stream of data to a file is called output stream. Java implements streams within the classes that are defined in java.io package. Types of streams Character Stream Byte Stream Character Stream The two super classes in character stream are Reader and Writer. Byte Stream The two super clasess in byte stream are InputStream and OutputStream from which most of the other classes are derived.

32 Character Stream Classes Character stream is defined by using two abstract class at the top of hierarchy, they are Reader and Writer. Some important Character Stream classes:

33 Byte Stream Classes Byte stream is defined by using two abstract class at the top of hierarchy, they are InputStream and OutputStream. Some important Byte Stream classes:

34 I/O HANDLING USING CHARACTER STREAM Reading Console Input: BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Reading Characters from Console: int read( ) throws IOException Example import java.io.*; public class BRRead public static void main(string args[]) throws IOException char c; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter characters, 'q' to quit."); // read characters do c = (char) br.read(); System.out.println(c); while(c!= 'q');

35 OUTPUT: Z:\Java Programs\Examples\IOStreams>javac BRRead.java Z:\Java Programs\Examples\IOStreams>java BRRead Enter characters, 'q' to quit. ABC 2013q A B C q Z:\Programs\javapgm\RUN\STREAMS>

36 Reading Strings from Console: String readline( ) throws IOException Example import java.io.*; public class BRReadLines public static void main(string args[]) throws IOException BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str; System.out.println("Enter lines of text."); System.out.println("Enter 'end' to quit."); do str = br.readline(); System.out.println(str); while(!str.equals("end"));

37 OUTPUT: Z:\Java Programs\Examples\IOStreams>javac BRReadLines.java Z:\Java Programs\Examples\IOStreams>java BRReadLines Enter lines of text. Enter 'end' to quit. WELCOME CCET WELCOME CCET 2013 end 2013 end hi hi end end Z:\Programs\javapgm\RUN\STREAMS>

38 Writing Console Output: void write(int byteval) Example import java.io.*; // Demonstrate System.out.write(). public class WriteDemo public static void main(string args[]) int b; b = 'A'; System.out.write(b); System.out.write('\n'); Output: Z:\Java Programs\Examples\IOStreams>javac WriteDemo.java Z:\Java Programs\Examples\IOStreams>java WriteDemo A

39 OUTPUT STREAM READING AND WRITING FILES

40 INPUT STREAM

41 I/O HANDLING USING BYTE STREAM FileInputStream: InputStream f = new FileInputStream( Z://java//hello"); File f = new File( Z://java//hello"); InputStream f = new FileInputStream(f); FileOutputStream: OutputStream f = new FileOutputStream( Z://java//hello") File f = new File( Z://java//hello"); OutputStream f = new FileOutputStream(f);

42 FILEINPUTSTREAM Example 1 import java.io.*; class FileInputStream1 public static void main (String args[]) throws IOException int n; InputStream ips=new FileInputStream("Z:\\Java Programs\\Examples\\IOStreams\\BRRead.java"); System.out.println("Total Bytes: "+(n=ips.available())); int m = n-390; System.out.println("\nReading first " +m+ " bytes at a time"); for(int i=0;i<m;i++) System.out.print((char)ips.read()); System.out.println("\n Skipping some text"); ips.skip(n/2); System.out.println("\n Still Available: " +ips.available()); ips.close();

43 Output Z:\Java Programs\Examples\IOStreams>javac FileInputStream1.java Z:\Java Programs\Examples\IOStreams>java FileInputStream1 Total Bytes: 394 Reading first 4 bytes at a time impo Skipping some text Still Available: 193 Z:\Java Programs\Examples\IOStreams>

44 FILEINPUTSTREAM Example 2 import java.io.*; class FileInputStream2 public static void main(string args[]) throws Exception FileInputStream fn = new FileInputStream("Z:\\Java Programs\\Examples\\IOStreams\\Input.txt"); int i; while((i=fn.read())!= -1) System.out.println((char)i); fn.close();

45 Output Z:\Java Programs\Examples\IOStreams>javac FileInputStream2.java Z:\Java Programs\Examples\IOStreams>java FileInputStream2 W e l c o m e t o C C E T Z:\Java Programs\Examples\IOStreams>

46 FILEOUTPUTSTREAM Example 1 import java.io.*; class FileOutStream1 public static void main (String args[]) throws Exception String text="hello, " + "Welcome to Chettinad"; byte b[] = text.getbytes(); OutputStream fobj = new FileOutputStream("Z:\\Java Programs\\Examples\\IOStreams\\Output.txt"); for(int i=0;i<b.length;i++) fobj.write(b[i]); System.out.println("\n The data is written to the file"); fobj.close();

47 Output Z:\Java Programs\Examples\IOStreams>javac FileOutStream1.java Z:\Java Programs\Examples\IOStreams>java FileOutStream1 The data is written to the file Z:\Java Programs\Examples\IOStreams> Output.txt Hello, Welcome to Chettinad

48 FILEOUTPUTSTREAM Example 2 import java.io.*; class FileOutStream2 public static void main(string args[]) throws Exception FileOutputStream fout = new FileOutputStream("Z:\\Java Programs\\Examples\\IOStreams\\Out.txt"); String s = "JAVA PROGRAMMING"; byte b[] = s.getbytes(); fout.write(b); fout.close(); System.out.println("Success...");

49 Output Z:\Java Programs\Examples\IOStreams>javac FileOutStream2.java Z:\Java Programs\Examples\IOStreams>java FileOutStream2 Success... Z:\Java Programs\Examples\IOStreams> Z:\Java Programs\Examples\IOStreams>type out.txt JAVA PROGRAMMING

UNIT - II Object Oriented Programming - Inheritance

UNIT - II Object Oriented Programming - Inheritance UNIT - II Object Oriented Programming - Inheritance Topics to be Covered: 1. Inheritance 2. Class Hierarchy 3. Polymorphism 4. Dynamic Binding 5. Final Keyword 6. Abstract Classes 7. Object Class 8. Reflection

More information

Chettinad College of Engineering & Technology Department of Information Technology Internal Examination II (Answer Key)

Chettinad College of Engineering & Technology Department of Information Technology Internal Examination II (Answer Key) Chettinad College of Engineering & Technology Department of Information Technology Internal Examination II (Answer Key) Branch & Section : B.Tech-IT / III Date: 06.09.2014 Semester : III Year V Sem Max.

More information

Byte and Character Streams. Reading and Writing Console input and output

Byte and Character Streams. Reading and Writing Console input and output Byte and Character Streams Reading and Writing Console input and output 1 I/O basics The io package supports Java s basic I/O (input/output) Java does provide strong, flexible support for I/O as it relates

More information

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: www: materials: e-learning environment: office: alt. office: jkizito@cis.mak.ac.ug http://serval.ug/~jona http://serval.ug/~jona/materials/csc1214

More information

Files and IO, Streams. JAVA Standard Edition

Files and IO, Streams. JAVA Standard Edition Files and IO, Streams JAVA Standard Edition Java - Files and I/O The java.io package contains nearly every class you might ever need to perform input and output (I/O) in Java. All these streams represent

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies Streams A stream is a sequence of data. In Java a stream is composed of bytes. In java, 3 streams are created for us automatically. 1. System.out : standard output stream 2. System.in : standard input

More information

1.00 Lecture 30. Sending information to a Java program

1.00 Lecture 30. Sending information to a Java program 1.00 Lecture 30 Input/Output Introduction to Streams Reading for next time: Big Java 15.5-15.7 Sending information to a Java program So far: use a GUI limited to specific interaction with user sometimes

More information

File IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20

File IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20 File IO Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 I/O Package Overview Package java.io Core concept: streams Ordered sequences of data that have a source

More information

public Candy() { ingredients = new ArrayList<String>(); ingredients.add("sugar");

public Candy() { ingredients = new ArrayList<String>(); ingredients.add(sugar); Cloning Just like the name implies, cloning is making a copy of something. To be true to the nature of cloning, it should be an exact copy. While this can be very useful, it is not always necessary. For

More information

Tirgul 1. Course Guidelines. Packages. Special requests. Inner classes. Inner classes - Example & Syntax

Tirgul 1. Course Guidelines. Packages. Special requests. Inner classes. Inner classes - Example & Syntax Tirgul 1 Today s topics: Course s details and guidelines. Java reminders and additions: Packages Inner classes Command Line rguments Primitive and Reference Data Types Guidelines and overview of exercise

More information

IT101. File Input and Output

IT101. File Input and Output IT101 File Input and Output IO Streams A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents

More information

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O Week 12 Streams and File I/O Overview of Streams and File I/O Text File I/O 1 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file

More information

needs to be reliable, easy to change, retarget efficiency is secondary implemented as interpreter, with virtual machine

needs to be reliable, easy to change, retarget efficiency is secondary implemented as interpreter, with virtual machine Java history invented mainly by James Gosling ([formerly] Sun Microsystems) 1990: Oak language for embedded systems needs to be reliable, easy to change, retarget efficiency is secondary implemented as

More information

Today. Book-keeping. File I/O. Subscribe to sipb-iap-java-students. Inner classes. Debugging tools

Today. Book-keeping. File I/O. Subscribe to sipb-iap-java-students. Inner classes.  Debugging tools Today Book-keeping File I/O Subscribe to sipb-iap-java-students Inner classes http://sipb.mit.edu/iap/java/ Debugging tools Problem set 1 questions? Problem set 2 released tomorrow 1 2 So far... Reading

More information

1993: renamed "Java"; use in a browser instead of a microwave : Sun sues Microsoft multiple times over Java

1993: renamed Java; use in a browser instead of a microwave : Sun sues Microsoft multiple times over Java Java history invented mainly by James Gosling ([formerly] Sun Microsystems) 1990: Oak language for embedded systems needs to be reliable, easy to change, retarget efficiency is secondary implemented as

More information

09-1. CSE 143 Java GREAT IDEAS IN COMPUTER SCIENCE. Overview. Data Representation. Representation of Primitive Java Types. Input and Output.

09-1. CSE 143 Java GREAT IDEAS IN COMPUTER SCIENCE. Overview. Data Representation. Representation of Primitive Java Types. Input and Output. CSE 143 Java Streams Reading: 19.1, Appendix A.2 GREAT IDEAS IN COMPUTER SCIENCE REPRESENTATION VS. RENDERING 4/28/2002 (c) University of Washington 09-1 4/28/2002 (c) University of Washington 09-2 Topics

More information

Lecture 11.1 I/O Streams

Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 1 OBJECT ORIENTED PROGRAMMING Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 2 Outline I/O Basics Streams Reading characters and string 21/04/2014 Ebtsam AbdelHakam

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

Basic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO)

Basic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO) I/O and Scannar Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 I/O operations Three steps:

More information

PIC 20A Streams and I/O

PIC 20A Streams and I/O PIC 20A Streams and I/O Ernest Ryu UCLA Mathematics Last edited: December 7, 2017 Why streams? Often, you want to do I/O without paying attention to where you are reading from or writing to. You can read

More information

Abstract Classes and Interfaces

Abstract Classes and Interfaces Abstract Classes and Interfaces Reading: Reges and Stepp: 9.5 9.6 CSC216: Programming Concepts Sarah Heckman 1 Abstract Classes A Java class that cannot be instantiated, but instead serves as a superclass

More information

CN208 Introduction to Computer Programming

CN208 Introduction to Computer Programming CN208 Introduction to Computer Programming Lecture #11 Streams (Continued) Pimarn Apipattanamontre Email: pimarn@pimarn.com 1 The Object Class The Object class is the direct or indirect superclass of every

More information

Special error return Constructors do not have a return value What if method uses the full range of the return type?

Special error return Constructors do not have a return value What if method uses the full range of the return type? 23 Error Handling Exit program (System.exit()) usually a bad idea Output an error message does not help to recover from the error Special error return Constructors do not have a return value What if method

More information

Object-Oriented Programming Design. Topic : Streams and Files

Object-Oriented Programming Design. Topic : Streams and Files Electrical and Computer Engineering Object-Oriented Topic : Streams and Files Maj Joel Young Joel Young@afit.edu. 18-Sep-03 Maj Joel Young Java Input/Output Java implements input/output in terms of streams

More information

Chapter 10 Input Output Streams

Chapter 10 Input Output Streams Chapter 10 Input Output Streams ICT Academy of Tamil Nadu ELCOT Complex, 2-7 Developed Plots, Industrial Estate, Perungudi, Chennai 600 096. Website : www.ictact.in, Email : contact@ictact.in, Phone :

More information

Inheritance. Lecture 11 COP 3252 Summer May 25, 2017

Inheritance. Lecture 11 COP 3252 Summer May 25, 2017 Inheritance Lecture 11 COP 3252 Summer 2017 May 25, 2017 Subclasses and Superclasses Inheritance is a technique that allows one class to be derived from another. A derived class inherits all of the data

More information

OBJECT ORIENTED PROGRAMMING. Course 4 Loredana STANCIU Room B616

OBJECT ORIENTED PROGRAMMING. Course 4 Loredana STANCIU Room B616 OBJECT ORIENTED PROGRAMMING Course 4 Loredana STANCIU loredana.stanciu@upt.ro Room B616 Inheritance A class that is derived from another class is called a subclass (also a derived class, extended class,

More information

Chapter 10. IO Streams

Chapter 10. IO Streams Chapter 10 IO Streams Java I/O The Basics Java I/O is based around the concept of a stream Ordered sequence of information (bytes) coming from a source, or going to a sink Simplest stream reads/writes

More information

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000 The Object Class Mark Allen Weiss Copyright 2000 1/4/02 1 java.lang.object All classes either extend Object directly or indirectly. Makes it easier to write generic algorithms and data structures Makes

More information

HST 952. Computing for Biomedical Scientists Lecture 8

HST 952. Computing for Biomedical Scientists Lecture 8 Harvard-MIT Division of Health Sciences and Technology HST.952: Computing for Biomedical Scientists HST 952 Computing for Biomedical Scientists Lecture 8 Outline Vectors Streams, Input, and Output in Java

More information

File Operations in Java. File handling in java enables to read data from and write data to files

File Operations in Java. File handling in java enables to read data from and write data to files Description Java Basics File Operations in Java File handling in java enables to read data from and write data to files along with other file manipulation tasks. File operations are present in java.io

More information

Here is a hierarchy of classes to deal with Input and Output streams.

Here is a hierarchy of classes to deal with Input and Output streams. PART 15 15. Files and I/O 15.1 Reading and Writing Files A stream can be defined as a sequence of data. The InputStream is used to read data from a source and the OutputStream is used for writing data

More information

Here is a hierarchy of classes to deal with Input and Output streams.

Here is a hierarchy of classes to deal with Input and Output streams. PART 25 25. Files and I/O 25.1 Reading and Writing Files A stream can be defined as a sequence of data. The InputStream is used to read data from a source and the OutputStream is used for writing data

More information

Sri Vidya College of Engineering & Technology Question Bank

Sri Vidya College of Engineering & Technology Question Bank 1. What is exception? UNIT III EXCEPTION HANDLING AND I/O Part A Question Bank An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program s instructions.

More information

Java Input/Output. 11 April 2013 OSU CSE 1

Java Input/Output. 11 April 2013 OSU CSE 1 Java Input/Output 11 April 2013 OSU CSE 1 Overview The Java I/O (Input/Output) package java.io contains a group of interfaces and classes similar to the OSU CSE components SimpleReader and SimpleWriter

More information

The static keyword Used to denote fields and methods that belong to a class (but not to any particular object).

The static keyword Used to denote fields and methods that belong to a class (but not to any particular object). Contents Topic 05 -Interfaces and Inner Classes I. Review: - visibility (public, protected/private), static, abstract, polymorphism, dynamic binding II Interface - Introduction Example 1 - Working with

More information

Lesson 3: Accepting User Input and Using Different Methods for Output

Lesson 3: Accepting User Input and Using Different Methods for Output Lesson 3: Accepting User Input and Using Different Methods for Output Introduction So far, you have had an overview of the basics in Java. This document will discuss how to put some power in your program

More information

CS 251 Intermediate Programming Java I/O Streams

CS 251 Intermediate Programming Java I/O Streams CS 251 Intermediate Programming Java I/O Streams Brooke Chenoweth University of New Mexico Spring 2018 Basic Input/Output I/O Streams mostly in java.io package File I/O mostly in java.nio.file package

More information

CPSC 319. Week 2 Java Basics. Xiaoyang Liu & Sorting Algorithms

CPSC 319. Week 2 Java Basics. Xiaoyang Liu & Sorting Algorithms CPSC 319 Week 2 Java Basics Xiaoyang Liu xiaoyali@ucalgary.ca & Sorting Algorithms Java Basics Variable Declarations Type Size Range boolean 1 bit true, false char 16 bits Unicode characters byte 8 bits

More information

Software Practice 1 - File I/O

Software Practice 1 - File I/O Software Practice 1 - File I/O Stream I/O Buffered I/O File I/O with exceptions CSV format Practice#6 Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim (42) T.A. Sujin Oh Junseong Lee 1 (43) / 38 2 / 38

More information

CS Week 11. Jim Williams, PhD

CS Week 11. Jim Williams, PhD CS 200 - Week 11 Jim Williams, PhD This Week 1. Exam 2 - Thursday 2. Team Lab: Exceptions, Paths, Command Line 3. Review: Muddiest Point 4. Lecture: File Input and Output Objectives 1. Describe a text

More information

INHERITANCE. Spring 2019

INHERITANCE. Spring 2019 INHERITANCE Spring 2019 INHERITANCE BASICS Inheritance is a technique that allows one class to be derived from another A derived class inherits all of the data and methods from the original class Suppose

More information

Java in 21 minutes. Hello world. hello world. exceptions. basic data types. constructors. classes & objects I/O. program structure.

Java in 21 minutes. Hello world. hello world. exceptions. basic data types. constructors. classes & objects I/O. program structure. Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static

More information

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods. Inheritance Inheritance is the act of deriving a new class from an existing one. Inheritance allows us to extend the functionality of the object. The new class automatically contains some or all methods

More information

Full file at Chapter 2 - Inheritance and Exception Handling

Full file at   Chapter 2 - Inheritance and Exception Handling Chapter 2 - Inheritance and Exception Handling TRUE/FALSE 1. The superclass inherits all its properties from the subclass. ANS: F PTS: 1 REF: 76 2. Private members of a superclass can be accessed by a

More information

I/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O

I/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O I/O 10-7-2013 I/O in Java I/O streams vs. Reader/Writer HW#3 due today Reading Assignment: Java tutorial on Basic I/O public class Swimmer implements Cloneable { public Date geteventdate() { return (Date)

More information

SRI VIDYA COLLEGE OF ENGG & TECH UNIT -2 INHERITANCE AND INTERFACES SVCET

SRI VIDYA COLLEGE OF ENGG & TECH UNIT -2 INHERITANCE AND INTERFACES SVCET Inheritance and Interfaces 2.1 UNIT -2 INHERITANCE AND INTERFACES 2.1 Inheritance Inheritance is the mechanism in java by which one class is allow to inherit the features (fields and methods) of another

More information

Object Oriented Design with UML and Java. PART VIII: Java IO

Object Oriented Design with UML and Java. PART VIII: Java IO Object Oriented Design with UML and Java PART VIII: Java IO Copyright David Leberknight and Ron LeMaster. Version 2011 java.io.* & java.net.* Java provides numerous classes for input/output: java.io.inputstream

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Overview CSE 143. Input and Output. Streams. Other Possible Kinds of Stream Converters. Stream after Stream... CSE143 Wi

Overview CSE 143. Input and Output. Streams. Other Possible Kinds of Stream Converters. Stream after Stream... CSE143 Wi CSE 143 Overview Topics Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 2/3/2005 (c) 2001-5, University of Washington 12-1 2/3/2005 (c) 2001-5,

More information

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA 1. JIT meaning a. java in time b. just in time c. join in time d. none of above CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA 2. After the compilation of the java source code, which file is created

More information

to avoid building a class hierarchy of factories that parallels the class hierarchy of products; or

to avoid building a class hierarchy of factories that parallels the class hierarchy of products; or Prototype Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype Applicability Use the Prototype pattern when a system should be independent

More information

Agenda & Reading. Python Vs Java. COMPSCI 230 S Software Construction

Agenda & Reading. Python Vs Java. COMPSCI 230 S Software Construction COMPSCI 230 S2 2016 Software Construction File Input/Output 2 Agenda & Reading Agenda: Introduction Byte Streams FileInputStream & FileOutputStream BufferedInputStream & BufferedOutputStream Character

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

CS 200 File Input and Output Jim Williams, PhD

CS 200 File Input and Output Jim Williams, PhD CS 200 File Input and Output Jim Williams, PhD This Week 1. WaTor Change Log 2. Monday Appts - may be interrupted. 3. Optional Lab: Create a Personal Webpage a. demonstrate to TA for same credit as other

More information

Good Earth School Naduveerapattu Date: Marks: 70

Good Earth School Naduveerapattu Date: Marks: 70 Good Earth School Naduveerapattu Date:.2.207 Marks: 70 Class: XI Second Term Examination Computer Science Answer Key Time: 3 hrs. Candidates are allowed additional 5 minutes for only reading the paper.

More information

Java Input / Output. CSE 413, Autumn 2002 Programming Languages.

Java Input / Output. CSE 413, Autumn 2002 Programming Languages. Java Input / Output CSE 413, Autumn 2002 Programming Languages http://www.cs.washington.edu/education/courses/413/02au/ 18-November-2002 cse413-18-javaio 2002 University of Washington 1 Reading Readings

More information

Course Content. Objectives of Lecture 22 File Input/Output. Outline of Lecture 22. CMPUT 102: File Input/Output Dr. Osmar R.

Course Content. Objectives of Lecture 22 File Input/Output. Outline of Lecture 22. CMPUT 102: File Input/Output Dr. Osmar R. Structural Programming and Data Structures Winter 2000 CMPUT 102: Input/Output Dr. Osmar R. Zaïane Course Content Introduction Objects Methods Tracing Programs Object State Sharing resources Selection

More information

Chapter 3 Classes & Objects

Chapter 3 Classes & Objects 1 Chapter 3 Classes & Objects Question 1: Given the code below, 1. public class Try 3. private static int sum = 20; 4. public static void main(string args[]) 5. { 6. Try t1 = new Try(); 7. Try.sum++; 8.

More information

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 2.A. Design a superclass called Staff with details as StaffId, Name, Phone, Salary. Extend this class by writing three subclasses namely Teaching (domain, publications), Technical (skills), and Contract

More information

Techniques of Java Programming: Streams in Java

Techniques of Java Programming: Streams in Java Techniques of Java Programming: Streams in Java Manuel Oriol May 8, 2006 1 Introduction Streams are a way of transferring and filtering information. Streams are directed pipes that transfer information

More information

Learning objectives: Enhancing Classes. CSI1102: Introduction to Software Design. More about References. The null Reference. The this reference

Learning objectives: Enhancing Classes. CSI1102: Introduction to Software Design. More about References. The null Reference. The this reference CSI1102: Introduction to Software Design Chapter 5: Enhancing Classes Learning objectives: Enhancing Classes Understand what the following entails Different object references and aliases Passing objects

More information

Java Programs. System.out.println("Dollar to rupee converion,enter dollar:");

Java Programs. System.out.println(Dollar to rupee converion,enter dollar:); Java Programs 1.)Write a program to convert rupees to dollar. 60 rupees=1 dollar. class Demo public static void main(string[] args) System.out.println("Dollar to rupee converion,enter dollar:"); int rs

More information

Selected Java Topics

Selected Java Topics Selected Java Topics Introduction Basic Types, Objects and Pointers Modifiers Abstract Classes and Interfaces Exceptions and Runtime Exceptions Static Variables and Static Methods Type Safe Constants Swings

More information

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Sec. 19.1, Appendix A2 11/2/2003 (c) 2001-3,

More information

File Processing in Java

File Processing in Java What is File I/O? File Processing in Java I/O is an abbreviation for input and output. Input is data coming in at runtime. Input come sin through a mouse, keyboard, touchscreen, microphone and so on. Output

More information

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Au

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Au Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Sec. 19.1, Appendix A2 11/2/2003 (c) 2001-3,

More information

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Sp

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Sp Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 4/27/2004 (c) 2001-4, University of

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays

More information

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE CSE 143 Overview Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 10/20/2004 (c) 2001-4, University of

More information

Lab 2: File Input and Output

Lab 2: File Input and Output Lab 2: File Input and Output This lab introduces how to handle files as both input and output. We re coming back to Tracery (which you implemented in Lab 1) with this assignment but instead of always reading

More information

Learning the Java Language. 2.1 Object-Oriented Programming

Learning the Java Language. 2.1 Object-Oriented Programming Learning the Java Language 2.1 Object-Oriented Programming What is an Object? Real world is composed by different kind of objects: buildings, men, women, dogs, cars, etc. Each object has its own states

More information

Input, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003

Input, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003 Input, Output and Exceptions COMS W1007 Introduction to Computer Science Christopher Conway 24 June 2003 Input vs. Output We define input and output from the perspective of the programmer. Input is data

More information

CSE 143 Lecture 25. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides adapted from Marty Stepp

CSE 143 Lecture 25. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides adapted from Marty Stepp CSE 143 Lecture 25 I/O Streams; Exceptions; Inheritance read 9.3, 6.4 slides adapted from Marty Stepp http://www.cs.washington.edu/143/ Input and output streams stream: an abstraction of a source or target

More information

WOSO Source Code (Java)

WOSO Source Code (Java) WOSO 2017 - Source Code (Java) Q 1 - Which of the following is false about String? A. String is immutable. B. String can be created using new operator. C. String is a primary data type. D. None of the

More information

CSE 143 Lecture 21. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp

CSE 143 Lecture 21. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp CSE 143 Lecture 21 I/O Streams; Exceptions; Inheritance read 9.3, 6.4 slides created by Marty Stepp http://www.cs.washington.edu/143/ Input and output streams stream: an abstraction of a source or target

More information

CSE 143 Lecture 22. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp

CSE 143 Lecture 22. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp CSE 143 Lecture 22 I/O Streams; Exceptions; Inheritance read 9.3, 6.4 slides created by Marty Stepp http://www.cs.washington.edu/143/ Input and output streams stream: an abstraction of a source or target

More information

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended JAVA Classes Class definition complete definition [public] [abstract] [final] class Name [extends Parent] [impelements ListOfInterfaces] {... // class body public public class abstract no instance can

More information

AN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS

AN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS JAVALEARNINGS.COM AN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS Visit for more pdf downloads and interview related questions JAVALEARNINGS.COM /* Write a program to write n number of student records

More information

Java: introduction to object-oriented features

Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Inheritance. The Java Platform Class Hierarchy

Inheritance. The Java Platform Class Hierarchy Inheritance In the preceding lessons, you have seen inheritance mentioned several times. In the Java language, classes can be derived from other classes, thereby inheriting fields and methods from those

More information

Inheritance (Part 5) Odds and ends

Inheritance (Part 5) Odds and ends Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there

More information

Dining philosophers (cont)

Dining philosophers (cont) Administrivia Assignment #4 is out Due Thursday April 8, 10:00pm no late assignments will be accepted Sign up in labs this week for a demo time Office hour today will be cut short (11:30) Another faculty

More information

CISC 323 (Week 9) Design of a Weather Program & Java File I/O

CISC 323 (Week 9) Design of a Weather Program & Java File I/O CISC 323 (Week 9) Design of a Weather Program & Java File I/O Jeremy Bradbury Teaching Assistant March 8 & 10, 2004 bradbury@cs.queensu.ca Programming Project The next three assignments form a programming

More information

CMSC 331 Second Midterm Exam

CMSC 331 Second Midterm Exam 1 20/ 2 80/ 331 First Midterm Exam 11 November 2003 3 20/ 4 40/ 5 10/ CMSC 331 Second Midterm Exam 6 15/ 7 15/ Name: Student ID#: 200/ You will have seventy-five (75) minutes to complete this closed book

More information

Streams and File I/O

Streams and File I/O Chapter 9 Streams and File I/O Overview of Streams and File I/O Text File I/O Binary File I/O File Objects and File Names Chapter 9 Java: an Introduction to Computer Science & Programming - Walter Savitch

More information

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass? 1. Overriding Methods A subclass can modify behavior inherited from a parent class. A subclass can create a method with different functionality than the parent s method but with the same: Name Return type

More information

Selected Questions from by Nageshwara Rao

Selected Questions from  by Nageshwara Rao Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)

More information

Building Java Programs. Inheritance and Polymorphism

Building Java Programs. Inheritance and Polymorphism Building Java Programs Inheritance and Polymorphism Input and output streams stream: an abstraction of a source or target of data 8-bit bytes flow to (output) and from (input) streams can represent many

More information

Basic Principles of OO. Example: Ice/Water Dispenser. Systems Thinking. Interfaces: Describing Behavior. People's Roles wrt Systems

Basic Principles of OO. Example: Ice/Water Dispenser. Systems Thinking. Interfaces: Describing Behavior. People's Roles wrt Systems Basics of OO Programming with Java/C# Basic Principles of OO Abstraction Encapsulation Modularity Breaking up something into smaller, more manageable pieces Hierarchy Refining through levels of abstraction

More information

Overloaded Methods. Sending Messages. Overloaded Constructors. Sending Parameters

Overloaded Methods. Sending Messages. Overloaded Constructors. Sending Parameters Overloaded Methods Sending Messages Suggested Reading: Bruce Eckel, Thinking in Java (Fourth Edition) Initialization & Cleanup 2 Overloaded Constructors Sending Parameters accessor method 3 4 Sending Parameters

More information

CMSC131. Creating a Datatype Class Continued Exploration of Memory Model. Reminders

CMSC131. Creating a Datatype Class Continued Exploration of Memory Model. Reminders CMSC131 Creating a Datatype Class Continued Exploration of Memory Model Reminders The name of the source code file needs to match the name of the class. The name of the constructor(s) need(s) to match

More information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

More information

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8 Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(

More information

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

(800) Toll Free (804) Fax   Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days Course Description This course introduces the Java programming language and how to develop Java applications using Eclipse 3.0. Students learn the syntax of the Java programming language, object-oriented

More information

Getting Started in Java. Bill Pugh Dept. of Computer Science Univ. of Maryland, College Park

Getting Started in Java. Bill Pugh Dept. of Computer Science Univ. of Maryland, College Park Getting Started in Java Bill Pugh Dept. of Computer Science Univ. of Maryland, College Park Hello, World In HelloWorld.java public class HelloWorld { public static void main(string [] args) { System.out.println(

More information

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

CS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide

CS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide CS1092: Tutorial Sheet: No 3 Exceptions and Files Tutor s Guide Preliminary This tutorial sheet requires that you ve read Chapter 15 on Exceptions (CS1081 lectured material), and followed the recent CS1092

More information

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages References Exceptions "Handling Errors with Exceptions", Java tutorial http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html CSE 413, Autumn 2005 Programming Languages http://www.cs.washington.edu/education/courses/413/05au/

More information