SWC test question #01. Using objects part I
|
|
- Tracy Terry
- 6 years ago
- Views:
Transcription
1 SWC test question #01 Using objects part I
2 Using objects part I Give a presentation of the concept objects, and how you use objects You could describe Types Variables Variable definitions The assignment operator Objects and Classes Method definitions Method parameters Return values Material: Objects First with Java, chapter 1, 2 You can refer to the attached code example during the test, if you wish.
3 Using objects part I public class BankAccount private double balance; public BankAccount() balance = 0; public void deposit(double amount) balance = balance + amount; public void withdraw(double amount) balance = balance - amount; public double getbalance() return balance;
4 Using objects part I public class BankAccountTester public BankAccountTester() public void runtest() BankAccount myaccount = new BankAccount(); myaccount.deposit(1000.0); myaccount.withdraw(500.0); myaccount.withdraw(400.0); System.out.println("Expected result is 100.0"); System.out.print("Actual result is "); System.out.println(myAccount.getBalance());
5 SWC test question #02 Using objects part II
6 Using objects part II Give a presentation of the concept objects, and how you use objects You could describe Objects and Classes Method definitions Method parameters Return values Method categories (accessors and mutators) Constructors Object construction Object references Material: Objects First with Java, chapter 1, 2, 3 You can refer to the attached code example during the test, if you wish.
7 Using objects part II public class Employee private String name; private double salary; public Employee(String aname, double asalary) name = aname; salary = asalary; public String getname() return name; public double getsalary() return salary; public void increasesalary(double bypercent) salary = (1 + bypercent/100.0)*salary;
8 Using objects part II public class EmployeeTester public EmployeeTester() public void runtest() Employee john = new Employee("John", 20000); System.out.println("Expected result: John "); System.out.print("Actual result: "); System.out.print(john.getName()); System.out.print(" "); System.out.println(john.getSalary()); john.increasesalary(30); System.out.println("Expected result: John "); System.out.print("Actual result: "); System.out.print(john.getName()); System.out.print(" "); System.out.println(john.getSalary());
9 SWC test question #03 Class Definitions part I
10 Class Definitions part I Give a presentation of the concept classes, and how you implement a class You could describe Encapsulation and abstraction Public interface Constructors Method definition (parameters, return types) Instance fields Access keyword (public and private) Using comments Material: Objects First with Java, chapter 2, 3 You can refer to the attached code example during the test, if you wish.
11 Class Definitions part I /** * Simulates a very simple bank account Per */ public class BankAccount private double balance; /** * Constructs a bank account with an initial balance of zero */ public BankAccount() balance = 0; /** * Deposits amount, i.e. increases balance by amount amount The actual amount */ public void deposit(double amount) balance = balance + amount; ( continues )
12 Class Definitions part I ( continued ) /** * Withdraws amount, i.e. decreases balance by amount amount The actual amount */ public void withdraw(double amount) balance = balance - amount; /** * Gets the current balance The current balance */ public double getbalance() return balance;
13 SWC test question #04 Class Definitions part II
14 Class Definitions part II Give a presentation of the concept classes, and how you implement a class You could describe Public interface Constructors Method definition (parameters, return types) Instance fields Access keyword (public and private) Implementing constructors and methods Categories of variables (instance fields, parameters, local variables) Lifetime of variables Method parameters The this keyword Material: Objects First with Java, chapter 2, 3 You can refer to the attached code example during the test, if you wish.
15 Class Definitions part II public class Employee private String name; private double salary; /** * Creates a new Employee record aname Employee name asalary Initial employee salary */ public Employee(String aname, double asalary) this.name = aname; this.salary = asalary; /** * Returns the employee name Employee name */ public String getname() return name; ( continues )
16 Class Definitions part II ( continued ) /** * Returns the employee salary Employee salary */ public double getsalary() return salary; /** * Increase salary by the given percentage bypercent Salary increase in percent */ public void increasesalary(double bypercent) double newsalary = (1 + bypercent/100)*salary; salary = newsalary;
17 SWC test question #05 Data Types
18 Data Types Give a presentation of data types. You could describe Number types (size, representation) Constants (purpose, definition) Assignment Increment and Decrement Strings Primitive types vs object types Casting, Type conversions Material: Objects First with Java, chapter 1, 2, 3 You can refer to the attached code example during the test, if you wish.
19 Data Types public class MilitaryTime private int timeinmins; public MilitaryTime(String timestr) String hourstr = timestr.substring(0,2); String minstr = timestr.substring(2,4); timeinmins = Integer.parseInt(hourStr)*60 + Integer.parseInt(minStr); public int gettimeinminutes() return timeinmins;
20 Data Types public class MilitaryTimeDiff private MilitaryTime timestart; private MilitaryTime timeend; private final int minsinhour = 60; private final int minsinday = 1440; public MilitaryTimeDiff(String start, String end) timestart = new MilitaryTime(start); timeend = new MilitaryTime(end); (continues )
21 Data Types (continued ) public int getdiffhours() return (getdiffinmins() / minsinhour); public int getdiffmins() return (getdiffinmins() % minsinhour); private int getdiffinmins() int diff = timeend.gettimeinminutes() - timestart.gettimeinminutes(); diff = (diff + minsinday) % minsinday; return diff;
22 SWC test question #06 Collections
23 Collections Give a presentation of collections, with primary focus on the ArrayList class. You could describe General purpose of collections ArrayList definition Accessing elements in an ArrayList ArrayList methods (add, get, remove, size, ) Arrays and loops Comparison with array structure Material: Objects First with Java, chapter 4 You can refer to the attached code example during the test, if you wish.
24 Collections public class AlternateSum private ArrayList<Integer> numbers; public AlternateSum() numbers = new ArrayList<Integer>(); public void findalternatingsum() getnumbersfromuser(); int sum = calculatealternatingsum(); JOptionPane.showMessageDialog(null, Sum is " + sum); ( continues )
25 Collections ( continued ) private void getnumbersfromuser() boolean done = false; while (!done) String input = JOptionPane.showInputDialog( Enter numbers "); if (input.equalsignorecase("q")) done = true; else numbers.add(integer.parseint(input)); ( continues )
26 Collections ( continued ) private int calculatealternatingsum() int altsum = 0; for (int index = 0; index < numbers.size(); index++) if ((index % 2) == 0) altsum = altsum + numbers.get(index); else altsum = altsum - numbers.get(index); return altsum;
27 SWC test question #07 Conditional Statements
28 Conditional Statements Give a presentation of conditional statements (the if statement) in Java. You could describe if statement structure if statement and flowcharts Formulation of conditions, logical operators Comparison of values, simple types Comparison of values, objects if/else statement Multiple alternatives Comparison with loop statements Material: Objects First with Java, chapter 2, 3 You can refer to the attached code example and diagrams during the test, if you wish.
29 Conditional Statements
30 Conditional Statements
31 Conditional Statements public class PayCheck public final double overtimehourlimit = 40.0; public final double overtimewagesrate = 1.5; public PayCheck() public double computethepay(double hourlywages, double hoursworked) double totalpay = 0.0; if (hoursworked > overtimehourlimit) double normalpay = hourlywages*overtimehourlimit; double overtimehours = hoursworked - overtimehourlimit; double overtimehourlywages = hourlywages * overtimewagesrate; double overtimepay = overtimehours * overtimehourlywages; totalpay = normalpay + overtimepay; else totalpay = hourlywages * hoursworked; return totalpay;
32 SWC test question #08 Loop Statements
33 Loop Statements Give a presentation of loop statements (while- and for- loops). You could describe while loop structure while loop flowchart for loop structure Infinite loops Conditions, logical operators The for-each loop Comparison of loop statement types (when to use which type) Material: Objects First with Java, chapter 4 You can refer to the attached code example and diagrams during the test, if you wish.
34 Loop Statements
35 Loop Statements public class CurrencyConverter private boolean userquits; public void convert() userquits = false; double rate = getexchangerate(); while (!userquits) String userinput = getuserinput(); userquits = userinput.equals("q"); if (!userquits) double dollaramount = Double.parseDouble(userInput); double euroamount = dollaramount / rate; presentresult(euroamount); ( continues )
36 Loop Statements ( continued ) private double getexchangerate() String ratestr = JOptionPane.showInputDialog("Enter $-euro exchange rate : "); return (Double.parseDouble(rateStr)); private String getuserinput() return JOptionPane.showInputDialog("Enter dollar amount (or Q to quit) : "); private void presentresult(double euroamount) JOptionPane.showMessageDialog(null, "Amount in euro : " + euroamount);
37 SWC test question #09 Testing
38 Testing Give a presentation of testing topics. You could describe Syntax errors Logical errors Positive and negative testing Regression testing Unit testing and test automation Manual walkthroughs Print statements Debuggers Material: Objects First with Java, Chapter 6 You can refer to the attached code example during the test, if you wish.
39 Testing public class BankAccount private double balance; public BankAccount() balance = 0; public void deposit(double amount) balance = balance + amount; public void withdraw(double amount) balance = balance - amount; public double getbalance() return balance;
40 Testing public class BankAccountTester public BankAccountTester() public void runtest() BankAccount myaccount = new BankAccount(); myaccount.deposit(1000.0); myaccount.withdraw(500.0); myaccount.withdraw(400.0); System.out.println("Expected result is 100.0"); System.out.print("Actual result is "); System.out.println(myAccount.getBalance());
41 SWC test question #10 Inheritance part I
42 Inheritance Part I Give a presentation of inheritance. You could describe Purpose of inheritance Syntax in Java for inheritance Superclasses and subclasses Access rights Initialisation in subclasses Polymorphic variables Type conversion and casting Interfaces and abstract classes Material: Big Java, chapter 8, 9 You can refer to the attached code example during the test, if you wish.
43 Inheritance Part I public class Employee private String name; private double salary; public Employee(String name, double salary) this.name = name; this.salary = salary; public String getname() return name; public double getsalary() return salary;
44 Inheritance Part I public class TemporaryEmployee extends Employee private int monthstobeemployed; public TemporaryEmployee(String name, double salary, int monthstobeemployed) super(name, salary); this.monthstobeemployed = monthstobeemployed; public String getmonthstobeemployed() return monthstobeemployed;
45 Inheritance Part I public class TestEmployee public void runtest() Employee e = new Employee( Jim, ); TemporaryEmployee te = new TemporaryEmployee( Sandy, ,6); Employee ve = e; // OK? TemporaryEmployee tve = e; // OK? ve = te; // OK? tve = te; // OK?
46 SWC test question #11 Inheritance part II
47 Inheritance Part II Give a presentation of inheritance. You could describe Purpose of inheritance Superclasses and subclasses Static types and dynamic types Method overriding and method polymorphism Dynamic method lookup Calling superclass methods in subclasses Abstract methods and abstract classes Interfaces Material: Big Java, chapter 8, 9 You can refer to the attached code example during the test, if you wish.
48 Inheritance Part II public class Employee private String name; private double salary; public Employee(String name, double salary) this.name = name; this.salary = salary; public String getname() return name; public double getsalary() return salary;
49 Inheritance Part II public class Manager extends Employee private double monthlybonus; public Manager(String name, double salary, double monthlybonus) super(name, salary); this.monthlybonus = monthlybonus; public double getsalary() return (super.getsalary() + monthlybonus);
50 Inheritance Part II public class TestEmployee public void runtest() Employee e = new Employee( Jim, ); Manager m = new Manager( Jacob, ,5000.0); System.out.println(e.getSalary()); System.out.println(m.getSalary()); Employee ev = m; System.out.println(ev.getSalary());
51 SWC test question #12 Graphical User Interface
52 Graphical User Interface Give a presentation of graphical user interfaces (GUI). You could describe Separation of GUI and logic GUI libraries in Java GUI components GUI layout and layout managers Frames, panels and containers Event-based applications Event handling Material: Big Java, chapter , 17 You can refer to the attached code example during the test, if you wish.
53 Graphical User Interface public class SomeControls private JFrame frame; public SomeControls() createcontrols(); private void createcontrols() frame = new JFrame("Some Controls"); JPanel mainpanel = new JPanel(); mainpanel.setlayout(new FlowLayout()); JButton but1 = new JButton("One"); mainpanel.add(but1); JButton but2 = new JButton("Two"); mainpanel.add(but2); frame.add(mainpanel); frame.setvisible(true);
54 Graphical User Interface
Sample Solution Assignment 5. Question R3.1
Sample Solution Assignment 5 Question R3.1 The interface of a class is the part that the user interacts with, not necessarily knowing how it works. An implementation of is the creation of this interface.
More informationpublic class Account { private int id; private static int nextaccountid = 0; private String name; private double balance;
public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance; public double deposit(double amount) { public double withdraw(double amount) {
More informationEncapsulation. Mason Vail Boise State University Computer Science
Encapsulation Mason Vail Boise State University Computer Science Pillars of Object-Oriented Programming Encapsulation Inheritance Polymorphism Abstraction (sometimes) Object Identity Data (variables) make
More informationHandout 9 OO Inheritance.
Handout 9 CS603 Object-Oriented Programming Fall 2016 Page 1 of 11 Handout 9 OO Inheritance. All classes in Java form a hierarchy. The top of the hierarchy is class Object Example: classicalarchives.com
More informationPractice problem on defining and using Class types. Part 4.
CS180 Programming Fundamentals Practice problem on defining and using Class types. Part 4. Implementing object associations: Applications typically consist of collections of objects of different related
More informationJava Inheritance. Classes implement the concept of ADT:
Java Inheritance Rui Moreira Class ADT (Abstract Data Type) Classes implement the concept of ADT: n Provide a coherent representation for the declaration of structured data types and also the code for
More informationContents. 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 informationBasic Object-Oriented Concepts. 5-Oct-17
Basic Object-Oriented Concepts 5-Oct-17 Concept: An object has behaviors In old style programming, you had: data, which was completely passive functions, which could manipulate any data An object contains
More informationCSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017
This week the main activity was a quiz activity, with a structure similar to our Friday lecture activities. The retrospective for the quiz is in Quiz-07- retrospective.pdf This retrospective explores the
More informationObject-Oriented Programming (Java)
Object-Oriented Programming (Java) Topics Covered Today 2.1 Implementing Classes 2.1.1 Defining Classes 2.1.2 Inheritance 2.1.3 Method equals and Method tostring 2 Define Classes class classname extends
More informationInheritance and Subclasses
Software and Programming I Inheritance and Subclasses Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Outline Packages Inheritance Polymorphism Sections 9.1 9.4 slides are available at www.dcs.bbk.ac.uk/
More information1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code:
1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code: public double getsalary() double basesalary = getsalary(); return basesalary + bonus; 3- What does the
More informationIntro to Computer Science 2. Inheritance
Intro to Computer Science 2 Inheritance Admin Questions? Quizzes Midterm Exam Announcement Inheritance Inheritance Specializing a class Inheritance Just as In science we have inheritance and specialization
More informationChapter 10 Inheritance. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved.
Chapter 10 Inheritance Chapter Goals To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package
More informationHandout 8 Classes and Objects Continued: Static Variables and Constants.
Handout 8 CS603 Object-Oriented Programming Fall 16 Page 1 of 8 Handout 8 Classes and Objects Continued: Static Variables and Constants. 1. Static variable Declared with keyword static One per class (instead
More informationSuper-Classes and sub-classes
Super-Classes and sub-classes Subclasses. Overriding Methods Subclass Constructors Inheritance Hierarchies Polymorphism Casting 1 Subclasses: Often you want to write a class that is a special case of an
More informationChapter Goals. Chapter 9 Inheritance. Inheritance Hierarchies. Inheritance Hierarchies. Set of classes can form an inheritance hierarchy
Chapter Goals To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package access control To
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 informationAPCS Semester #1 Final Exam Practice Problems
Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester
More informationQuarter 1 Practice Exam
University of Chicago Laboratory Schools Advanced Placement Computer Science Quarter 1 Practice Exam Baker Franke 2005 APCS - 12/10/08 :: 1 of 8 1.) (10 percent) Write a segment of code that will produce
More informationCOMP-202 Unit 8: Defining Your Own Classes. CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation
COMP-202 Unit 8: Defining Your Own Classes CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation Defining Our Own Classes (1) So far, we have been creating
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationInheritance Advanced Programming ICOM 4015 Lecture 11 Reading: Java Concepts Chapter 13
Inheritance Advanced Programming ICOM 4015 Lecture 11 Reading: Java Concepts Chapter 13 Fall 2006 Adapted from Java Concepts Companion Slides 1 Chapter Goals To learn about inheritance To understand how
More informationCHAPTER 10 INHERITANCE
CHAPTER 10 INHERITANCE Inheritance Inheritance: extend classes by adding or redefining methods, and adding instance fields Example: Savings account = bank account with interest class SavingsAccount extends
More informationENCAPSULATION AND POLYMORPHISM
MODULE 3 ENCAPSULATION AND POLYMORPHISM Objectives > After completing this lesson, you should be able to do the following: Use encapsulation in Java class design Model business problems using Java classes
More informationICOM 4015: Advanced Programming
ICOM 4015: Advanced Programming Lecture 3 Reading: Chapter Three: Implementing Classes Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter Three - Implementing Classes Chapter Goals To become
More informationModule Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1
UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2015-16 PROGRAMMING 1 CMP-4008Y Time allowed: 2 hours Section A (Attempt all questions: 80 marks) Section B (Attempt one
More informationClasses and Inheritance Extending Classes, Chapter 5.2
Classes and Inheritance Extending Classes, Chapter 5.2 Dr. Yvon Feaster Inheritance Inheritance defines a relationship among classes. Key words often associated with inheritance are extend and implements.
More informationInheritance (P1 2006/2007)
Inheritance (P1 2006/2007) Fernando Brito e Abreu (fba@di.fct.unl.pt) Universidade Nova de Lisboa (http://www.unl.pt) QUASAR Research Group (http://ctp.di.fct.unl.pt/quasar) Chapter Goals To learn about
More informationAgenda: Notes on Chapter 3. Create a class with constructors and methods.
Bell Work 9/19/16: How would you call the default constructor for a class called BankAccount? Agenda: Notes on Chapter 3. Create a class with constructors and methods. Objectives: To become familiar with
More informationChapter 7. Inheritance
Chapter 7 Inheritance Introduction to Inheritance Inheritance is one of the main techniques of objectoriented programming (OOP) Using this technique, a very general form of a class is first defined and
More informationJava Programming Unit 4. Abstract Classes, Interfaces, Polymorphism
Java Programming Unit 4 Abstract Classes, Interfaces, Polymorphism Abstract Classes A class is called abstract if it was declared with the abstract keyword. You can not instanjate an abstract class. Usually,
More informationCSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism
CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism Review from Lecture 22 Added parent pointers to the TreeNode to implement increment and decrement operations on tree
More informationJava for Non Majors Spring 2018
Java for Non Majors Spring 2018 Final Study Guide The test consists of 1. Multiple choice questions - 15 x 2 = 30 points 2. Given code, find the output - 3 x 5 = 15 points 3. Short answer questions - 3
More informationThis exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.
York University AS/AK/ITEC 2610 3.0 All Sections OBJECT-ORIENTED PROGRAMMING Midterm Test Duration: 90 Minutes This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for
More informationObject-oriented basics. Object Class vs object Inheritance Overloading Interface
Object-oriented basics Object Class vs object Inheritance Overloading Interface 1 The object concept Object Encapsulation abstraction Entity with state and behaviour state -> variables behaviour -> methods
More informationImplementing Classes
Implementing Classes Advanced Programming ICOM 4015 Lecture 3 Reading: Java Concepts Chapter 3 Fall 2006 Slides adapted from Java Concepts companion slides 1 Chapter Goals To become familiar with the process
More informationProgramming Language Concepts: Lecture 2
Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 2, 19 January 2009 Classes and
More informationOutline CSE 142. Specification vs Implementation - Review. CSE142 Wi03 F-1. Instance Variables
Outline CSE 142 Class Implementation in Java Implementing classes in Java Instance variables properties Value-returning methods for queries Void methods for commands Return statement Assignment statement
More informationSyllabus & Curriculum for Certificate Course in Java. CALL: , for Queries
1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads
More informationThe Scanner class reads data entered by the user. Methods: COSC Dr. Ramon Lawrence. Page 3. COSC Dr. Ramon Lawrence A) A = 6, B = 3
COSC 123 Computer Creativity Course Review Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Reading Data from the User The Scanner Class The Scanner class reads data entered
More informationCS 180 Final Exam Review 12/(11, 12)/08
CS 180 Final Exam Review 12/(11, 12)/08 Announcements Final Exam Thursday, 18 th December, 10:20 am 12:20 pm in PHYS 112 Format 30 multiple choice questions 5 programming questions More stress on topics
More informationLearn more about our research, discover data science, and find other great resources at:
Learn more about our research, discover data science, and find other great resources at: http://www.dataminingapps.com Chapter 7 Delving Further into Object- Oriented Concepts Overview Annotations Overloading
More informationChapter Goals. Chapter 7 Designing Classes. Discovering Classes Actors (end in -er, -or) objects do some kinds of work for you: Discovering Classes
Chapter Goals Chapter 7 Designing Classes To learn how to discover appropriate classes for a given problem To understand the concepts of cohesion and coupling To minimize the use of side effects To document
More informationFunctional Programming, Classes, and Recursion!
CS 1301 Homework 9 Functional Programming, Classes, and Recursion! Due: Monday, April 20 th before 11:55 pm THIS IS AN INDIVIDUAL ASSIGNMENT! Students are expected to abide by the Georgia Tech Honor Code.
More informationJava for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.
Java for Non Majors Final Study Guide April 26, 2017 The test consists of 1. Multiple choice questions 2. Given code, find the output 3. Code writing questions 4. Code debugging question 5. Short answer
More informationCSEN401 Computer Programming Lab. Topics: Introduction and Motivation Recap: Objects and Classes
CSEN401 Computer Programming Lab Topics: Introduction and Motivation Recap: Objects and Classes Prof. Dr. Slim Abdennadher 16.2.2014 c S. Abdennadher 1 Course Structure Lectures Presentation of topics
More informationCLASS DESIGN. Objectives MODULE 4
MODULE 4 CLASS DESIGN Objectives > After completing this lesson, you should be able to do the following: Use access levels: private, protected, default, and public. Override methods Overload constructors
More informationCS105 C++ Lecture 7. More on Classes, Inheritance
CS105 C++ Lecture 7 More on Classes, Inheritance " Operator Overloading Global vs Member Functions Difference: member functions already have this as an argument implicitly, global has to take another parameter.
More informationIntroduction to Inheritance
Introduction to Inheritance James Brucker These slides cover only the basics of inheritance. What is Inheritance? One class incorporates all the attributes and behavior from another class -- it inherits
More informationJava Programming Lecture 6
Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components
More informationEduardo M. Breijo Baullosa May 2, Assignment 17. Report
Eduardo M. Breijo Baullosa May 2, 2012 Cesar I. Cruz ICOM4015 Assignment 17 Report The Automated teller machine is a computer that allows the interaction between bank account information and its respective
More informationInheritance & Abstract Classes Fall 2018 Margaret Reid-Miller
Inheritance & Abstract Classes 15-121 Margaret Reid-Miller Today Today: Finish circular queues Exercise: Reverse queue values Inheritance Abstract Classes Clone 15-121 (Reid-Miller) 2 Object Oriented Programming
More informationChapter Goals. T To understand the concept of regression testing. Chapter 6 Arrays and Array Lists. Arrays Array: Sequence of values of the same type
Chapter Goals To become familiar with using arrays and array lists To learn about wrapper classes, auto-boxing and the generalized for loop To study common array algorithms To learn how to use two-dimensional
More informationImplementing Classes (P1 2006/2007)
Implementing Classes (P1 2006/2007) Fernando Brito e Abreu (fba@di.fct.unl.pt) Universidade Nova de Lisboa (http://www.unl.pt) QUASAR Research Group (http://ctp.di.fct.unl.pt/quasar) Chapter Goals To become
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationBasics of Java Programming. Hendrik Speleers
Hendrik Speleers Overview Building blocks of a Java program Classes Objects Primitives Methods Memory management Making a (simple) Java program Baby example Bank account system A Java program Consists
More informationObject-Oriented Programming Paradigm
Object-Oriented Programming Paradigm Sample Courseware Object-Oriented Programming Paradigm Object-oriented programming approach allows programmers to write computer programs by representing elements of
More informationTopic 7: Inheritance. Reading: JBD Sections CMPS 12A Winter 2009 UCSC
Topic 7: Inheritance Reading: JBD Sections 7.1-7.6 1 A Quick Review of Objects and Classes! An object is an abstraction that models some thing or process! Examples of objects:! Students, Teachers, Classes,
More informationEmployee class: Attributes: Methods:
Employee class: name: the name of the employee. rank: rank in the company structure (1-15). yearsofexperience: number of years of experience for the employee. Employee (name: String, rank: int, yearsofexperience:
More informationInformatik II. Tutorial 6. Mihai Bâce Mihai Bâce. April 5,
Informatik II Tutorial 6 Mihai Bâce mihai.bace@inf.ethz.ch 05.04.2017 Mihai Bâce April 5, 2017 1 Overview Debriefing Exercise 5 Briefing Exercise 6 Mihai Bâce April 5, 2017 2 U05 Some Hints Variables &
More informationCS Exam 1 Review Suggestions
CS 235 - Fall 2015 - Exam 1 Review Suggestions p. 1 last modified: 2015-09-30 CS 235 - Exam 1 Review Suggestions You are responsible for material covered in class sessions, lab exercises, and homeworks;
More informationObject-Oriented Programming in Java. Topic : Objects and Classes (cont) Object Oriented Design
Electrical and Computer Engineering Object-Oriented in Java Topic : Objects and Classes (cont) Object Oriented Maj Joel Young Joel.Young@afit.edu 11-Sep-03 Maj Joel Young Using Class Instances Accessing
More informationhttps://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.aspx?m=5507&c=618&mo=18917&t=191&sy=2012&bl...
Page 1 of 13 Units: - All - Teacher: ProgIIIJavaI, CORE Course: ProgIIIJavaI Year: 2012-13 Intro to Java How is data stored by a computer system? What does a compiler do? What are the advantages of using
More informationLecture 15: Inheritance II
Lecture 15: Inheritance II Building Java Programs: A Back to Basics Approach by Stuart Reges and Marty Stepp Copyright (c) Pearson 2013. All rights reserved. Interacting with the superclass Changes to
More information2/9/2012. Chapter Three: Implementing Classes. Chapter Goals
Chapter Three: Implementing Classes Chapter Goals To become familiar with the process of implementing classes To be able to implement simple methods To understand the purpose and use of constructors To
More information9/2/2011. Chapter Goals
Chapter Goals To become familiar with the process of implementing classes To be able to implement simple methods To understand the purpose and use of constructors To understand how to access instance fields
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 information1 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 informationSEEM4570 System Design and Implementation. Lecture 11 From Design to Implementation
SEEM4570 System Design and Implementation Lecture 11 From Design to Implementation Introduction We learned programming and we learned UML, but separately. Now, the question is how can we translate a design
More informationCSC 175 Intermediate Programming
CSC 175 Intermediate Programming Lecture 6 Inheritance Inheritance and Derived Classes Inheritance is the process by which a new class is created from another class. The new class is called the derived
More informationEncapsulation in C++
pm_jat@daiict.ac.in In abstract sense, it is all about information hiding Informally, you can call it as packaging of data and function together in a single entity called class such that you get implementation
More informationGROUP - A <10 questions x 4 points each = 40 points >
GROUP - A For each question, write in the box the output of the shown fragment. If you believe the fragment will not produce output due to errors, write the
More informationCS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance
CS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance Handout written by Julie Zelenski, updated by Jerry. Inheritance is a language property most gracefully supported by the object-oriented
More informationCISC370: Inheritance
CISC370: Inheritance Sara Sprenkle 1 Questions? Review Assignment 0 due Submissions CPM Accounts Sara Sprenkle - CISC370 2 1 Quiz! Sara Sprenkle - CISC370 3 Inheritance Build new classes based on existing
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 information22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time: 3 Hrs.
Scheme I Sample Question Paper Program Name : Computer Engineering Program Group Program Code : CO/CM/IF/CW Semester : Third 22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time:
More informationLecture 07: Object Encapsulation & References AITI Nigeria Summer 2012 University of Lagos.
Accelerating Information Technology Innovation http://aiti.mit.edu Lecture 07: Object Encapsulation & References AITI Nigeria Summer 2012 University of Lagos. Data Field Encapsulation Sometimes we want
More informationInheritance. = way of forming new classes based on existing ones = way to share/reuse codebetween two or more classes
Inheritance 49 Inheritance Definitions = way of forming new classes based on existing ones = way to share/reuse codebetween two or more classes Terminology superclass: Parent class being inherited from
More informationInformatik II Tutorial 6. Subho Shankar Basu
Informatik II Tutorial 6 Subho Shankar Basu subho.basu@inf.ethz.ch 06.04.2017 Overview Debriefing Exercise 5 Briefing Exercise 6 2 U05 Some Hints Variables & Methods beginwithlowercase, areverydescriptiveand
More informationCS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM
CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM This handout explains what you have to know for the first prelim. Terms and their meaning Below, we summarize the terms you should
More informationBig software. code reuse: The practice of writing program code once and using it in many contexts.
Inheritance Big software software engineering: The practice of conceptualizing, designing, developing, documenting, and testing largescale computer programs. Large-scale projects face many issues: getting
More informationJava Programming Lecture 7
Java Programming Lecture 7 Alice E. Fischer Feb 16, 2015 Java Programming - L7... 1/16 Class Derivation Interfaces Examples Java Programming - L7... 2/16 Purpose of Derivation Class derivation is used
More informationJAVA MOCK TEST JAVA MOCK TEST II
http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your
More informationOverview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008
Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object
More informationTeenCoder : Java Programming (ISBN )
TeenCoder : Java Programming (ISBN 978-0-9887070-2-3) and the AP * Computer Science A Exam Requirements (Alignment to Tennessee AP CS A course code 3635) Updated March, 2015 Contains the new 2014-2015+
More informationProgramming Exercise 14: Inheritance and Polymorphism
Programming Exercise 14: Inheritance and Polymorphism Purpose: Gain experience in extending a base class and overriding some of its methods. Background readings from textbook: Liang, Sections 11.1-11.5.
More informationInheritance: Definition
Inheritance 1 Inheritance: Definition inheritance: a parent-child relationship between classes allows sharing of the behavior of the parent class into its child classes one of the major benefits of object-oriented
More informationCOMPUTER SCIENCE DEPARTMENT PICNIC. Operations. Push the power button and hold. Once the light begins blinking, enter the room code
COMPUTER SCIENCE DEPARTMENT PICNIC Welcome to the 2016-2017 Academic year! Meet your faculty, department staff, and fellow students in a social setting. Food and drink will be provided. When: Saturday,
More informationSoftware and Programming 1
Software and Programming 1 Week 9 Lab - Use of Classes and Inheritance 8th March 2018 SP1-Lab9-2018.ppt Tobi Brodie (Tobi@dcs.bbk.ac.uk) 1 Lab 9: Objectives Exercise 1 Student & StudentTest classes 1.
More informationChapter 2a Class Relationships
Data Structures for Java William H. Ford William R. Topp Chapter 2a Class Relationships Bret Ford 2005, Prentice Hall Wrapper Classes Convert a value of primitive type to an object. Supply methods to access
More informationName 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 informationINTERFACE WHY INTERFACE
INTERFACE WHY INTERFACE Interfaces allow functionality to be shared between objects that agree to a contract on how the software should interact as a unit without needing knowledge of how the objects accomplish
More informationOVERRIDING. 7/11/2015 Budditha Hettige 82
OVERRIDING 7/11/2015 (budditha@yahoo.com) 82 What is Overriding Is a language feature Allows a subclass or child class to provide a specific implementation of a method that is already provided by one of
More informationLanguage 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 informationReview. these are the instance variables. these are parameters to the methods
Review Design a class to simulate a bank account Implement the class Write a demo program that creates bank accounts Write junit tests for the bank account class Review What data items are associated with
More informationSTUDENT LESSON A5 Designing and Using Classes
STUDENT LESSON A5 Designing and Using Classes 1 STUDENT LESSON A5 Designing and Using Classes INTRODUCTION: This lesson discusses how to design your own classes. This can be the most challenging part of
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 information$ % $ % BankAccount. public class BankAccount {... private??? balance; } "commands, transformers, mutators! "abstract state! "queries, accessors!
"! public class { private??? balance; "! # "! "commands, transformers, mutators! "abstract state! "queries, accessors! "constructors! & "! public class { private double balance; "! void "this! x.command1();
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 information