14-mar24

# 14-mar24 - 1 COMP 110 Static Methods and Variables Tabitha...

This preview shows pages 1–10. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 COMP 110 Static Methods and Variables Tabitha Peck M.S. March 24, 2008 MWF 3-3:50 pm Philips 367 2 Announcements • No Homework… yet 3 Questions? 4 Today in COMP 110 • Static Methods • A little review 5 Methods • Actions performed by objects – smiley.drawFace(); – this.setColor(“green”); – circumference? – area? 6 Static Methods • Methods that do not require an object of any kind – Where have you seen static before? – Invoke method with class name – SmileyClass.circumference(3); 7 Why no object? • What data is in the object? • When should you create a static method? 8 Writing a static method • Add static to the heading public static final double PI = 3.14159; public static double circumference(double radius) { return (PI*(radius + radius)); } 9 Writing a static method • Cannot do anything that refers to a calling object – Why? public static final double PI = 3.14159; private boolean smile = true; public static double circumference(double radius) { smile = false; return (PI*(radius + radius)); } NO 10...
View Full Document

## This note was uploaded on 02/02/2009 for the course COMP 110 taught by Professor Stotts during the Spring '08 term at UNC.

### Page1 / 23

14-mar24 - 1 COMP 110 Static Methods and Variables Tabitha...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online