(C) 2010 Pearson Education, Inc. All rights reserved.

Slides:



Advertisements
Similar presentations
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Advertisements

1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 1 Abstract Classes and Interfaces.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 Chapter 12 More OOP, Interfaces, and Inner Classes.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2006 Pearson Education, Inc. All rights reserved Templates.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
What is a class? a class definition is a blueprint to build objects its like you use the blueprint for a house to build many houses in the same way you.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Engineering Mechanics: Statics, Thirteenth Edition R. C. Hibbeler Copyright ©2013 by Pearson Education, Inc. All rights reserved. EXAMPLE 9.1.
The different types of variables in a Java program.
Review of C++ Programming Part II Sheng-Fang Huang.
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
Engineering Mechanics: Statics, Thirteenth Edition R. C. Hibbeler Copyright ©2013 by Pearson Education, Inc. All rights reserved. EXAMPLE 3.1.
Java Classes Appendix C © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 2.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
 2005 Pearson Education, Inc. All rights reserved. 1 Arrays Part 4.
 2005 Pearson Education, Inc. All rights reserved Classes and Objects: A Deeper Look.
Engineering Mechanics: Statics, Thirteenth Edition R. C. Hibbeler Copyright ©2013 by Pearson Education, Inc. All rights reserved. EXAMPLE 11.1.
Chapter 10 Classes and Objects: A Deeper Look Visual C# 2010 for Programmers © by Pearson Education, Inc. All Rights Reserved.
Android How to Program, 2/e © Copyright by Pearson Education, Inc. All Rights Reserved.
1 CSC241: Object Oriented Programming Lecture No 06.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 2.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Visual C# 2012 for Programmers © by Pearson Education, Inc. All Rights Reserved.
Dale Roberts Object Oriented Programming using Java - Final and Static Keywords Dale Roberts, Lecturer Computer Science, IUPUI
 2005 Pearson Education, Inc. All rights reserved Classes and Objects: A Deeper Look.
1 Chapter 5: Defining Classes. 2 Basics of Classes An object is a member of a class type What is a class? Fields & Methods Types of variables: –Instance:
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
1 Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 10 More on Objects and Classes.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 1.
 2005 Pearson Education, Inc. All rights reserved. 1 Introduction to Classes and Objects.
YG - CS Concept of Encapsulation What is encapsulation? - data and functions/methods are packaged together in the class normally.
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
 2006 Pearson Education, Inc. All rights reserved Templates.
Chapter 16 Universal Insurance Issues and International Comparisons of Health Care Systems.
© 2015 Pearson Education, Inc.
Chapter 20 Generic Classes and Methods
Operator Overloading; Class string
© 2015 Pearson Education, Inc.
Welcome App Android How to Program
Address Book App Android How to Program
Android Market and App Business Issues
Chapter 3 Introduction to Classes, Objects Methods and Strings
Chapter 3 Introduction to Classes, Objects Methods and Strings
Exception Handling: A Deeper Look
Chapter 6 Methods: A Deeper Look
Tip Calculator App Android How to Program
Doodlz App Android How to Program
Unit-1 Introduction to Java
Interfaces.
Advanced Java Programming
Multiple Inheritance & Interfaces
Route Tracker App Android How to Program
Static is one of the modifiers that determine variable and method characteristics. The static modifier associates a variable or method with its class.
Roots, Radicals, and Root Functions
Enhanced Slideshow App
Chapter 3 Introduction to Classes, Objects Methods and Strings
Chapter 8 Classes and Objects: A Deeper Look
Section 10.5 The Dot Product
Unit 4 Review Answers.
Creating and Using Classes
Presentation transcript:

(C) 2010 Pearson Education, Inc. All rights reserved. What is static? Java™ How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved. 8.11  static Class Members In certain cases, only one copy of a particular variable should be shared by all objects of a class. A static field—called a class variable—is used in such cases. A static variable represents classwide information—all objects of the class share the same piece of data. The declaration of a static variable begins with the keyword static. (C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved.

8.11 static Class Members (Cont.) A static method cannot access non-static class members, because a static method can be called even when no objects of the class have been instantiated. For the same reason, the this reference cannot be used in a static method. The this reference must refer to a specific object of the class, and when a static method is called, there might not be any objects of its class in memory. If a static variable is not initialized, the compiler assigns it a default value. (C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved.