Overview of the lecture. Some key issues in programming Java programming. CMPT Data and Program Abstraction. Some of the key programming issues
|
|
- Lawrence Watson
- 6 years ago
- Views:
Transcription
1 Overview of the lecture CMPT Data and Program Abstraction Instructor: Snezana Mitrovic-Minic Some key issues in programming Java programming equality of objects inheritance Is-a and has-a relationship Java interface dynamic binding and abstract classes Java exceptions 2 Some of the key programming issues Some key issues in programming Modularity Modifiability Easy of use Fail-safe programming Style Debugging 3 4 Modularity - How to determine modules? What helps: abstraction and information hiding procedural abstraction: separate the purpose of a method from its implementation data abstraction: Abstract Data Types (ADT) information hiding (all modules and ADTs should hide something) object-oriented design encapsulation - hides inner details inheritance - classes can inherit properties from other classes polymorphism - outcome of an operation depends on the objects on which the operation acts - determined at the execution time top-down design (emphasis on algorithm) address the problem at successively lower levels of details Modularity helps: modularity makes programming easier modularity permits team work modularity makes debugging easier modularity makes reading of a program easier modularity makes modifications easier modularity eliminates redundant code 5 6 1
2 Modifiability and Easy of use Modifiability - keep programmers in mind modifiability = easy to modify a program what helps: modularity, naming constants,... Fail-safe programming Program has to perform reasonably no matter how anyone uses it. Try to anticipate the ways people could misuse the program - and guard against it. Easy of use - keep users in mind friendly and good user interface prompt user for input, and echo the input label the output and make it easy to read,... How: check for errors in user input check for errors in logic method should enforce their preconditions and check the values of its arguments, Programming Style extensive use of methods use of private data fields error handling (in case of error, method should return a value or throw an exception) readability documentation an initial comment of the program (statement of purpose, author and date, description of the program s input and output, description of how to use program, assumptions (such as the type of data expected), statement of exceptions - what it could go wrong, brief description of major classes) initial comments in each class: state purpose and describe data contained initial comments for each method: state its purpose, preconditions, postconditions, and methods called comments in the body of each method: explain important features or subtle logic 9 Debugging Tracking down errors systematically. A programming environment with a debugger: stepping through a program, setting breakpoints, using watches Without a debugger: set your watches and temporary 6\V WHP RXWS ULQWOQ statements Use these debugging facilities - at strategic locations in a program place them at entry and departure points of a method check key variables at the beginning and ends of loops check variables that appear in LIÃexpression, beforeãliã statement place them at some other key points in a method use dump methods (methods for displaying complex data structures), Java Inheritance and more 11 public class Sphere { private double theradius; public Sphere() { setradius(1.0); public Sphere(double initialradius) { setradius(initialradius); return ((rhs instanceof Sphere) && (theradius == ((Sphere)rhs).theRadius)); public void setradius(double newradius) { if (newradius >= 0.0) { theradius = newradius; public double radius() { public double area() { public double volume() { public void displaystatistics() { //end Sphere 12 2
3 public class Sphere { private double theradius; public Sphere() { setradius(1.0); public Sphere(double initialradius) { setradius(initialradius); return ((rhs instanceof Sphere) && (theradius == ((Sphere)rhs).theRadius)); public void setradius(double newradius) { if (newradius >= 0.0) { theradius = newradius; public double radius() { public double area() { public double volume() { public void displaystatistics() { //end Sphere 13 public ColoredSphere(Color c, double initialradius) {... (theradius == ((Sphere)rhs).theRadius) && (color == ((Sphere)rhs).color)); public Color getcolor() { public ColoredSphere(Color c, double initialradius) {... (theradius == ((Sphere)rhs).theRadius) && (color == ((Sphere)rhs).color)); public Color getcolor() {... public ColoredSphere(Color c, double initialradius) {... (theradius == ((Sphere)rhs).theRadius) && (color == ((Sphere)rhs).color)); public Color getcolor() { Inheritance Sphere is a base class or superclass. ColoredSphere is a derived class or subclass of Sphere. Declaring a class without extends clause, implicitly extends the class Object. public ColoredSphere(Color c, double initialradius) {... (theradius == ((ColoredSphere)rhs).theRadius) && (color == ((ColoredSphere)rhs).color)); public Color getcolor() { Subclass: inherits the contents of the superclass public members of superclass are available in subclass constructor of a subclass has to invoke super() to call the constructor of the superclass. (super() has to precede all other statements in the constructor). methods of superclass can be overridden. Method in subclass overrides a method in superclass if the two methods have the same declaration 3
4 Is-a Relationship Inheritance should be used only when an is-a relationship exists between the superclass and the subclass. ColoredSphere is a Sphere An instance of a subclass can be used anywhere where an instance of the superclass can be used. Not the other way around. Actual argument in a call to a method can be a subclass of the corresponding formal parameter. For example: All the classes are derived from the Object class. Therefore, type Object can be used as the type of a formal parameter, and object of any class can be used as the actual argument. 19 public class Ball extends Sphere { private String thename; // the ball s name public Ball() { setname("unknown"); public Ball(double initialradius, String initialname) { super(initialradius); setname(initialname); return ((rhs instanceof Ball) && (radius() == ((Ball)rhs).radius()) && (thename.compareto(((ball)rhs).thename)==0) ); public void displaystatistics() { System.out.print("\nStatistics for a "+ name()); super.displaystatistics(); 20 Is-a Relationship (cont) Has-a Relationships Program uses Sphere and Ball. Program contains method: public void displayradius (Sphere thing) { System.out.println("Radius is " + thing.radius() +"."; A ball-point pen has a ball as its point. Use inheritance? Valid calls to the method are: Sphere mysphere = new Sphere(); ColoredSphere myball = new Ball(); displayradius(mysphere); displayradius(myball); Has-a Relationships A ball-point pen has a ball as its point. Has-a Relationships A ball-point pen has a ball as its point. Use inheritance? Use inheritance? Å because a pen is not a ball. Use data field point whose type is Ball. public class Pen { private Ball point;... Instance Pen has, or contains an instance of a Ball. Has-a relationship is sometimes called containment
5 Object equality Java package groups related classes together. sphere1.equals(sphere2) compares two references. You can customize HTXDOV for a class. If drawingpackage is to contain class Pallete: package drawingpackage; public class Pallete { To use classes from drawingpackage import drawingpackage.*; or to use one class from drawingpackage import drawingpackage.pallete; Java Access Modifiers control the visibility of the members of a class. public members can be used anywhere private members can be used by methods of the class protected members can be used only by methods of the class, methods of other classes in the same package, and methods of the subclasses Members declared without an access modifier are available to methods of the class and methods of other classes in the same package Java Interface Java Interface A Java interface specifies the common behavior of a set of classes. public interface AnimateInterface { public final double CONST = ; // a constant public void move(int x, int y); public void paint(); public class AnimateBall extends Ball implements AnimateInterface { Java Interface (cont) Example: Dog is an animal class Dog is a subclass of class Animal Dog is a Pet. But because Dog already has a superclass (Animal), the Dog cannot have another superclass. Therefore, in order to be sure that Dog implements methods needed for a Pet, we can create Pet interface, and... public interface PetInterface { public takewalk(); public class Dog extends Animal implements PetInterface {
6 Dynamic binding Ball myball = new Ball(1.25, basketball ); Sphere mysphere = myball; mysphere.displaystatistics(); Dynamic Binding mysphere references to instance of Ball class the Ball version of displaystatistics is executed. It is decided at execution time - late binding or dynamic binding. Also, displaystatistics of class Ball overrides displaystatistics of class Sphere Overriding and Overloading Two methods with the same name and the same set of parameters - one method overrides the other. Two methods with the same name and the different set of parameters - second method overloads the first. Frequently, you overload constructors. Abstract Classes Abstract class An abstract class has no instances and is used only as the basis of other classes. An abstract class - provide implementations of few methods (access to private data fields). A class that contains at least one abstract method must be declared as an abstract class. A subclass of an abstract class must be declared abstract if it does not provide implementations for all abstract methods of superclass. public abstract class EquidistantShape { private double theradius; // it can be protected instead of private public void setradius(double newradius) { if (newradius >= 0.0) { theradius = newradius; public double radius() { return theradius; public abstract void displaystatistics();
7 public class SphereP351 extends EquidistantShape { public SphereP351() { setradius(1.0); public SphereP351(double initialradius) { setradius(initialradius); // Implementation of abstract method public void displaystatistics() { System.out.println("\nRadius = " + radius() + "\ndiameter = " + diameter() + "\ncircumference = " + circumference() + "\narea = " + area() + "\nvolume = " + volume()); // Remaining methods for class appear here Exception is a mechanism for handling an error during execution. A method indicates that an error has occurred by throwing an exception. The exception returns to the point where the method was called, where you catch the exception and deal with the error condition. Exception is a mechanism for handling an error during execution. A method indicates that an error has occurred by throwing an exception. The exception returns to the point where the method was called, where you catch the exception and deal with the error condition. Java has two types of exceptions: checked exceptions - instances of java.lang.exception or its subclasses. They must be handled locally or explicitly thrown from the method. They are used for serious problems (FileNotFoundException, ) runtime exceptions - instances of RuntimeException class (a subclass of Exception) or of its subclasses. They are used when error is not considered as serious. These types of exceptions can be often handled by fail-safe programming Throwing exception: A method whose code can throw an exception: throw new exceptionclass(stringargument); Catching exception: try { statement(s); catch (exceptionclass identifier) { statement(s); public void mymethod() throws MyException { // some code throw new MyException ( May exception raised: reason )
Making New instances of Classes
Making New instances of Classes NOTE: revised from previous version of Lecture04 New Operator Classes are user defined datatypes in OOP languages How do we make instances of these new datatypes? Using
More informationImportant when developing large programs. easier to write, understand, modify, and debug. each module understood individually
Chapter 3: Data Abstraction Abstraction, modularity, information hiding Abstract data types Example-1: List ADT Example-2: Sorted list ADT C++ Classes C++ Namespaces C++ Exceptions 1 Fundamental Concepts
More informationData Abstraction: The Walls
Chapter 4 Data Abstraction: The Walls 2011 Pearson Addison-Wesley. All rights reserved 4-1 Abstract Data Types Modularity Keeps the complexity of a large program manageable by systematically controlling
More informationChapter 4.!Data Abstraction: The Walls! 2011 Pearson Addison-Wesley. All rights reserved 4-1
Chapter 4!Data Abstraction: The Walls! 2011 Pearson Addison-Wesley. All rights reserved 4-1 2015-09-29 11:44:25 1/45 Chapter-04.pdf (#4) bubblesort(int[] a) { int last = a.length - 1; while (last > 0)
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationObject Oriented Programming. Java-Lecture 11 Polymorphism
Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class
More informationChapter 10 Classes Continued. Fundamentals of Java
Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an
More informationCS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?
CS6501 - Internet programming Unit- I Part - A 1 Define Java. Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed to have the "look
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationArgument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.
Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar
More informationChapter 1: Programming Principles
Chapter 1: Programming Principles Object Oriented Analysis and Design Abstraction and information hiding Object oriented programming principles Unified Modeling Language Software life-cycle models Key
More informationCMSC 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 informationThe design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT
Designing an ADT The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT What data does a problem require? What operations does a problem
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes
More informationChapter 1: Principles of Programming and Software Engineering
Chapter 1: Principles of Programming and Software Engineering Data Abstraction & Problem Solving with C++ Fifth Edition by Frank M. Carrano Software Engineering and Object-Oriented Design Coding without
More informationException-Handling Overview
م.عبد الغني أبوجبل Exception Handling No matter how good a programmer you are, you cannot control everything. Things can go wrong. Very wrong. When you write a risky method, you need code to handle the
More informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
More informationCH. 2 OBJECT-ORIENTED PROGRAMMING
CH. 2 OBJECT-ORIENTED PROGRAMMING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) OBJECT-ORIENTED
More information15CS45 : OBJECT ORIENTED CONCEPTS
15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?
More informationCREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed
CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?
More informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationLecture Notes Chapter #9 Summery. Inheritance
Lecture Notes Chapter #9 Summery Inheritance Subclass inherits all members of its superclass except its constructors methods inherited from a superclass can overridden in the subclass o a method overrides
More informationCOMP200 - Object Oriented Programming: Test One Duration - 60 minutes
COMP200 - Object Oriented Programming: Test One Duration - 60 minutes Study the following class and answer the questions that follow: package shapes3d; public class Circular3DShape { private double radius;
More informationJava Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.
Java Inheritance Written by John Bell for CS 342, Spring 2018 Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Review Which of the following is true? A. Java classes may either
More informationInheritance. Transitivity
Inheritance Classes can be organized in a hierarchical structure based on the concept of inheritance Inheritance The property that instances of a sub-class can access both data and behavior associated
More informationOOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.
OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract
More informationQUESTIONS FOR AVERAGE BLOOMERS
MANTHLY TEST JULY 2017 QUESTIONS FOR AVERAGE BLOOMERS 1. How many types of polymorphism? Ans- 1.Static Polymorphism (compile time polymorphism/ Method overloading) 2.Dynamic Polymorphism (run time polymorphism/
More informationFull 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 informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationEXCEPTION HANDLING. Summer 2018
EXCEPTION HANDLING Summer 2018 EXCEPTIONS An exception is an object that represents an error or exceptional event that has occurred. These events are usually errors that occur because the run-time environment
More informationCS-202 Introduction to Object Oriented Programming
CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction
More informationInheritance and object compatibility
Inheritance and object compatibility Object type compatibility An instance of a subclass can be used instead of an instance of the superclass, but not the other way around Examples: reference/pointer can
More informationObject Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia
Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationObject Oriented Issues in VDM++
Object Oriented Issues in VDM++ Nick Battle, Fujitsu UK (nick.battle@uk.fujitsu.com) Background VDMJ implemented VDM-SL first (started late 2007) Formally defined. Very few semantic problems VDM++ support
More informationPROGRAMMING LANGUAGE 2
31/10/2013 Ebtsam Abd elhakam 1 PROGRAMMING LANGUAGE 2 Java lecture (7) Inheritance 31/10/2013 Ebtsam Abd elhakam 2 Inheritance Inheritance is one of the cornerstones of object-oriented programming. It
More informationLecture Chapter 2 Software Development
Lecture Chapter 2 Software Development Large Software Projects Software Design o Team of programmers o Cost effective development Organization Communication Problem Solving Analysis of the problem Multiple
More informationPractice for Chapter 11
Practice for Chapter 11 MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Object-oriented programming allows you to derive new classes from existing
More informationCompaq Interview Questions And Answers
Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not
More informationWhat s Conformance? Conformance. Conformance and Class Invariants Question: Conformance and Overriding
Conformance Conformance and Class Invariants Same or Better Principle Access Conformance Contract Conformance Signature Conformance Co-, Contra- and No-Variance Overloading and Overriding Inheritance as
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationHAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.
HAS-A Relationship Association is a relationship where all objects have their own lifecycle and there is no owner. For example, teacher student Aggregation is a specialized form of association where all
More informationLogistics. Final Exam on Friday at 3pm in CHEM 102
Java Review Logistics Final Exam on Friday at 3pm in CHEM 102 What is a class? A class is primarily a description of objects, or instances, of that class A class contains one or more constructors to create
More informationCMSC 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 informationProgram Correctness and Efficiency. Chapter 2
Program Correctness and Efficiency Chapter 2 Chapter Objectives To understand the differences between the three categories of program errors To understand the effect of an uncaught exception and why you
More informationWhat is Inheritance?
Inheritance 1 Agenda What is and Why Inheritance? How to derive a sub-class? Object class Constructor calling chain super keyword Overriding methods (most important) Hiding methods Hiding fields Type casting
More informationCS 251 Intermediate Programming Inheritance
CS 251 Intermediate Programming Inheritance Brooke Chenoweth University of New Mexico Spring 2018 Inheritance We don t inherit the earth from our parents, We only borrow it from our children. What is inheritance?
More information2.6 Error, exception and event handling
2.6 Error, exception and event handling There are conditions that have to be fulfilled by a program that sometimes are not fulfilled, which causes a so-called program error. When an error occurs usually
More informationCritique this Code. Hint: It will crash badly! (Next slide please ) 2011 Fawzi Emad, Computer Science Department, UMCP
Critique this Code string const & findsmallest(vector const &v) string smallest = v[0]; for (unsigned int i = 0; i < v.size(); i++) if (v[i] < smallest) smallest = v[i]; return smallest; Hint:
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationDeclarations and Access Control SCJP tips
Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for
More informationCO Java SE 8: Fundamentals
CO-83527 Java SE 8: Fundamentals Summary Duration 5 Days Audience Application Developer, Developer, Project Manager, Systems Administrator, Technical Administrator, Technical Consultant and Web Administrator
More informationObject Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance
CS257 Computer Science I Kevin Sahr, PhD Lecture 10: Inheritance 1 Object Oriented Features For a programming language to be called object oriented it should support the following features: 1. objects:
More informationLecture 2: Java & Javadoc
Lecture 2: Java & Javadoc CS 62 Fall 2018 Alexandra Papoutsaki & William Devanny 1 Instance Variables or member variables or fields Declared in a class, but outside of any method, constructor or block
More informationChapter 11 Inheritance and Polymorphism. Motivations. Suppose you will define classes to model circles,
Chapter 11 Inheritance and Polymorphism 1 Motivations Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common features. What is the best way to design
More informationData Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1
Design Principles Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques 2-1 Data Structures Data Structure - A systematic way of organizing and accessing
More informationInheritance. SOTE notebook. November 06, n Unidirectional association. Inheritance ("extends") Use relationship
Inheritance 1..n Unidirectional association Inheritance ("extends") Use relationship Implementation ("implements") What is inherited public, protected methods public, proteced attributes What is not inherited
More informationI pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.
Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone
More informationLecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting
Lecture 36: Cloning Last time: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Today: 1. Project #7 assigned 2. equals reconsidered 3. Copying and cloning 4. Composition 11/27/2006
More informationObjective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5
Objective Questions BCA Part III page 1 of 5 1. Java is purely object oriented and provides - a. Abstraction, inheritance b. Encapsulation, polymorphism c. Abstraction, polymorphism d. All of the above
More informationData Abstraction. Hwansoo Han
Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed
More informationInheritance & Polymorphism Recap. Inheritance & Polymorphism 1
Inheritance & Polymorphism Recap Inheritance & Polymorphism 1 Introduction! Besides composition, another form of reuse is inheritance.! With inheritance, an object can inherit behavior from another object,
More information24. Inheritance. Java. Fall 2009 Instructor: Dr. Masoud Yaghini
24. Inheritance Java Fall 2009 Instructor: Dr. Masoud Yaghini Outline Superclasses and Subclasses Using the super Keyword Overriding Methods The Object Class References Superclasses and Subclasses Inheritance
More informationProgramming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017
Programming Language Concepts Object-Oriented Programming Janyl Jumadinova 28 February, 2017 Three Properties of Object-Oriented Languages: Encapsulation Inheritance Dynamic method binding (polymorphism)
More informationCOMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed
1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every
More informationInheritance (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 informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationDOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS
Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully
More informationCLASSES AND OBJECTS IN JAVA
Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class
More informationClasses. Classes. Classes. Class Circle with methods. Class Circle with fields. Classes and Objects in Java. Introduce to classes and objects in Java.
Classes Introduce to classes and objects in Java. Classes and Objects in Java Understand how some of the OO concepts learnt so far are supported in Java. Understand important features in Java classes.
More informationPolymorphism. return a.doublevalue() + b.doublevalue();
Outline Class hierarchy and inheritance Method overriding or overloading, polymorphism Abstract classes Casting and instanceof/getclass Class Object Exception class hierarchy Some Reminders Interfaces
More informationIT101. Inheritance, Encapsulation, Polymorphism and Constructors
IT101 Inheritance, Encapsulation, Polymorphism and Constructors OOP Advantages and Concepts What are OOP s claims to fame? Better suited for team development Facilitates utilizing and creating reusable
More informationChapter 10 Inheritance and Polymorphism. Dr. Hikmat Jaber
Chapter 10 Inheritance and Polymorphism Dr. Hikmat Jaber 1 Motivations Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common features. What is the
More informationDay 4. COMP1006/1406 Summer M. Jason Hinek Carleton University
Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information
More information22. Inheritance. Java. Summer 2008 Instructor: Dr. Masoud Yaghini
22. Inheritance Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Superclasses and Subclasses Using the super Keyword Overriding Methods The Object Class References Inheritance Object-oriented programming
More informationConformance. Object-Oriented Programming Spring 2015
Conformance Object-Oriented Programming 236703 Spring 2015 1 What s Conformance? Overriding: replace method body in sub-class Polymorphism: subclass is usable wherever superclass is usable Dynamic Binding:
More informationCS 11 java track: lecture 3
CS 11 java track: lecture 3 This week: documentation (javadoc) exception handling more on object-oriented programming (OOP) inheritance and polymorphism abstract classes and interfaces graphical user interfaces
More informationMore on Objects in JAVA TM
More on Objects in JAVA TM Inheritance : Definition: A subclass is a class that extends another class. A subclass inherits state and behavior from all of its ancestors. The term superclass refers to a
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More informationCISC-124. Passing Parameters. A Java method cannot change the value of any of the arguments passed to its parameters.
CISC-124 20180215 These notes are intended to summarize and clarify some of the topics that have been covered recently in class. The posted code samples also have extensive explanations of the material.
More informationInheritance -- Introduction
Inheritance -- Introduction Another fundamental object-oriented technique is called inheritance, which, when used correctly, supports reuse and enhances software designs Chapter 8 focuses on: the concept
More informationCS 61B Data Structures and Programming Methodology. July 7, 2008 David Sun
CS 61B Data Structures and Programming Methodology July 7, 2008 David Sun Announcements You ve started (or finished) project 1, right? Package Visibility public declarations represent specifications what
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More information1.00 Lecture 13. Inheritance
1.00 Lecture 13 Inheritance Reading for next time: Big Java: sections 10.5-10.6 Inheritance Inheritance allows you to write new classes based on existing (super or base) classes Inherit super class methods
More informationObject-Oriented Programming
Object-Oriented Programming 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Object-Oriented
More informationFundamentals of Object Oriented Programming
INDIAN INSTITUTE OF TECHNOLOGY ROORKEE Fundamentals of Object Oriented Programming CSN- 103 Dr. R. Balasubramanian Associate Professor Department of Computer Science and Engineering Indian Institute of
More informationWhat does it mean by information hiding? What are the advantages of it? {5 Marks}
SECTION ONE (COMPULSORY) Question #1 [30 Marks] a) Describe the main characteristics of object-oriented programming. {5 Marks Encapsulation the ability to define a new type and a set of operations on that
More informationPESIT Bangalore South Campus
PESIT Bangalore South Campus 15CS45 : OBJECT ORIENTED CONCEPTS Faculty : Prof. Sajeevan K, Prof. Hanumanth Pujar Course Description: No of Sessions: 56 This course introduces computer programming using
More informationToday. Book-keeping. Inheritance. Subscribe to sipb-iap-java-students. Slides and code at Interfaces.
Today Book-keeping Inheritance Subscribe to sipb-iap-java-students Interfaces Slides and code at http://sipb.mit.edu/iap/java/ The Object class Problem set 1 released 1 2 So far... Inheritance Basic objects,
More informationCS61B Lecture #12. Programming Contest: Coming up Saturday 5 October. See the contest announcement page, here.
CS61B Lecture #12 Programming Contest: Coming up Saturday 5 October. See the contest announcement page, here. Lateness: Yes, the lateness policy does extend to Project 0. Test 1: still scheduled for 16
More informationCSEN401 Computer Programming Lab. Topics: Object Oriented Features: Abstraction and Polymorphism
CSEN401 Computer Programming Lab Topics: Object Oriented Features: Abstraction and Polymorphism Prof. Dr. Slim Abdennadher 23.2.2015 c S. Abdennadher 1 Object-Oriented Paradigm: Features Easily remembered
More informationIntroduction to Object-Oriented Programming
Introduction to Object-Oriented Programming Review 2: Object-Oriented Programming Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Review 2: Object-Oriented Programming 1 / 14 Topics
More informationENCAPSULATION. private, public, scope and visibility rules. packages and package level access.
ENCAPSULATION private, public, scope and visibility rules. packages and package level access. Q. Explain the term Encapsulation with an example? Ans: The wrapping up to data and methods into a single units
More informationUNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED
UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED EXERCISE 11.1 1. static public final int DEFAULT_NUM_SCORES = 3; 2. Java allocates a separate set of memory cells in each instance
More informationAssoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Marenglen Biba Exception handling Exception an indication of a problem that occurs during a program s execution. The name exception implies that the problem occurs infrequently. With exception
More informationCSE1720. General Info Continuation of Chapter 9 Read Chapter 10 for next week. Second level Third level Fourth level Fifth level
CSE1720 Click to edit Master Week text 08, styles Lecture 13 Second level Third level Fourth level Fifth level Winter 2014! Thursday, Feb 27, 2014 1 General Info Continuation of Chapter 9 Read Chapter
More informationExceptions. 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 informationHAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.
HAS-A Relationship Association is a weak relationship where all objects have their own lifetime and there is no ownership. For example, teacher student; doctor patient. If A uses B, then it is an aggregation,
More information