AP Java Ch. 4 Review 2014-2015. Question 1  Java methods can return only primitive types (int, double, boolean, etc).

Slides:



Advertisements
Similar presentations
Overloading Having more than one method with the same name is known as overloading. Overloading is legal in Java as long as each version takes different.
Advertisements

This is Java Jeopardy Writing Methods…chapter 4…
Based on Java Software Development, 5th Ed. By Lewis &Loftus
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 4: Writing Classes Presentation slides for Java Software Solutions for AP* Computer Science.
Interfaces A Java interface is a collection
1 Classes, Encapsulation, Methods and Constructors (Continued) Class definitions Instance data Encapsulation and Java modifiers Method declaration and.
Chapter 4: Writing Classes
© 2006 Pearson Education Chapter 4: Writing Classes Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition by John Lewis,
Functions CS 308 – Data Structures. Function Definition Define function header and function body Value-returning functions return-data-type function-name(parameter.
Chapter 3, More on Classes & Methods Clark Savage Turner, J.D., Ph.D. Copyright 2003 CSTurner, from notes and text.
Overloading methods review When is the return statement required? What do the following method headers tell us? public static int max (int a, int b)
1. 2 Introduction to Methods  Method Calls  Parameters  Return Type  Method Overloading  Accessor & Mutator Methods  Student Class: Revisited.
COMP 14 Introduction to Programming Miguel A. Otaduy May 25, 2004.
COMP 110 Introduction to Programming Mr. Joshua Stough October 8, 2007.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 8, 2005.
Chapter 4: Writing Classes Presentation slides for Java Software Solutions Foundations of Program Design Third Edition by John Lewis and William Loftus.
Chapter 7: User-Defined Methods
© 2007 Lawrenceville Press Slide 1 Chapter 7 Top-Down Development  Problem-solving approach  Breaking a task down into smaller subtasks  First level.
Encapsulation CMSC 202. Types of Programmers Class programmers – Developers of new classes – Goal: Expose the minimum interface necessary to use a new.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 4: Writing Classes Presentation slides for Java Software Solutions for AP* Computer Science.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Object-Oriented Programming (OOP). Implementing an OOD in Java Each class is stored in a separate file. All files must be stored in the same package.
© 2006 Pearson Education Chapter 4: Writing Classes Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition by John Lewis,
Copyright © 2002, Systems and Computer Engineering, Carleton University a-JavaReview.ppt * Object-Oriented Software Development Unit.
ECE122 Feb. 22, Any question on Vehicle sample code?
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
1 Methods Introduction to Methods Passing Arguments to a Method More About Local Variables Returning a Value from a Method Problem Solving with Methods.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 4.
Chapter 5 Introduction to Defining Classes
Chapter 3 Introduction to Classes and Objects Definitions Examples.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
User Defined Methods Methods are used to divide complicated programs into manageable pieces. There are predefined methods (methods that are already provided.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
Chapter 6 Methods Chapter 6 - Methods.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 4: Writing Classes Presentation slides for Java Software Solutions for AP* Computer Science.
1 Static Variable and Method Lecture 9 by Dr. Norazah Yusof.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 4: Writing Classes Presentation slides for Java Software Solutions for AP* Computer Science.
CLASS AND OBJECTS Valerie Chu, Ph.D. LeMoyne-Owen College 1.
 Static  Example for Static Field  Example for Static Method  Math class methods  Casting  Scope of Declaration  Method Overloading  Constructor.
Classes - Intermediate
Java Classes Introduction. Contents Introduction Objects and Classes Using the Methods in a Java Class – References and Aliases Defining a Java Class.
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
Function PrototypetMyn1 Function Prototype We can declare a function before we use or define it by means of a function prototype. A function prototype.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 7 User-Defined Methods.
Software Development Java Classes and Methods
Chapter 3: Using Methods, Classes, and Objects
Using local variable without initialization is an error.
Methods The real power of an object-oriented programming language takes place when you start to manipulate objects. A method defines an action that allows.
Java Programming with BlueJ
Defining Classes and Methods
An Introduction to Java – Part II
slides created by Ethan Apter
Classes, Encapsulation, Methods and Constructors (Continued)
Chapter 4 Writing Classes.
slides created by Ethan Apter
CS139 October 11, 2004.
Defining Classes and Methods
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
BBIT 212/ CISY 111 Object Oriented Programming (OOP)
JAVA CLASSES.
Class.
slides created by Ethan Apter and Marty Stepp
Review for Midterm 3.
Corresponds with Chapter 5
Presentation transcript:

AP Java Ch. 4 Review

Question 1  Java methods can return only primitive types (int, double, boolean, etc).

Question 2  All Java classes must contain a main method which is the first method executed when the Java class is called upon.

Question 3  Java methods can return more than one item if they are modified with the reserved word continue, as in public continue int foo( ) { … }

Question 4  The following method header definition will result in a syntax error: public void aMethod( );

Question 5  A method defined in a class can access the class’ instance data without needing to pass them as parameters or declare them as local variables.

Question 6  The interface of a class is based on those data instances and methods that are declared public.

Question 7  Defining formal parameters requires including each parameters type.

Question 8  Every class definition must include a constructor.

Question 9  While multiple objects of the same class can exist, there is only one version of the class.

Question 10  A constructor must always return an int.

Question 11  A class’s instance data are the variables declared in the main method.

Question 12  The return statement must be followed a single variable that contains the value to be returned.

Question 13  A method defined without a return statement will cause a compile error.

Question 14  The println method on System.out is overloaded.

Question 15  Method decomposition is the process of creating overloaded versions of a method that do the same thing, but operate on different data types.

Question 16  An object may be made up of other objects.

Question 17  In a method with both a precondition and a postcondition, the postcondition should be true when the method finishes executing regardless of whether the precondition was true.

Question 18  An accessor method provides access to a value and allows the caller to change that value.