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.

Slides:



Advertisements
Similar presentations
Color Templates Software Engineering Module: Core of Java Topic: Constructors TALENTSPRINT | © Copyright 2012.
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Programming With Java ICS201 University Of Hail1 Chapter 13 Inner Classes.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Static Members, Structures, Enumerations, Generic Classes, Namespaces Learning & Development Team Telerik Software Academy.
Chapter 4&5 Defining Classes Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Classes and Objects: Recap A typical Java program creates many objects which interact with one another by sending messages. Through the objects interactions,
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Unit 08 & 091 Nested Classes Introduction Inner Classes Local Classes Anonymous Classes Exercises.
Classes and Instances. Introduction Classes, Objects, Methods and Instance Variables Declaring a Class with a Method and Instantiating an Object of a.
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.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Classes and Objects  A typical Java program creates many objects which interact with one another by sending messages. Through the objects interactions,
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Unit 081 Introduction to Nested Classes Nested classes are classes defined within other classes The class that includes the nested class is called the.
Static Class Members Wrapper Classes Autoboxing Unboxing.
Slides prepared by Rose Williams, Binghamton University Chapter 13 Interfaces and Inner Classes.
Java Programming Review (Part I) Enterprise Systems Programming.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Objects, Classes and Syntax Dr. Andrew Wallace PhD BEng(hons) EurIng
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
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.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
CSI 3125, Preliminaries, page 1 Compiling the Program.
Static. 2 Objectives Introduce static keyword –examine syntax –describe common uses.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
SEEM Java – Basic Introduction, Classes and Objects.
CITA 342 Section 1 Object Oriented Programming (OOP)
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Classes, Interfaces and Packages
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Friend Function. 2 Any data which is declared private inside a class is not accessible from outside the class. A non-member function cannot have an access.
 Static  Example for Static Field  Example for Static Method  Math class methods  Casting  Scope of Declaration  Method Overloading  Constructor.
Topics Instance variables, set and get methods Encapsulation
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
Object and Classes อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 3.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Basic Class Structure. Class vs. Object class - a template for building an object –defines the instance data that the object will hold –defines instance.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
CLASSES IN JAVA Primitive Types Example of a Class Allocating Objects of a Class Protecting Class data Constructors Static data and Static Methods.
Methods, classes, and Objects Dr. Jim Burns. Question  Which of the following access modifiers is the default modifier?  public  private  protected.
3 Introduction to Classes and Objects.
Introduction to Classes and Objects
Yanal Alahmad Java Workshop Yanal Alahmad
Java Primer 1: Types, Classes and Operators
Internet and Java Foundations, Programming and Practice
Road Map Introduction to object oriented programming. Classes
Classes A class is a blueprint of an object
Chapter 3 Introduction to Classes, Objects Methods and Strings
Class Inheritance (Cont.)
Chapter 3 Introduction to Classes, Objects Methods and Strings
Defining Classes and Methods
Interface.
An Introduction to Java – Part II
Interfaces.
Static is one of the modifiers that determine variable and method characteristics. The static modifier associates a variable or method with its class.
Chapter 14 Abstract Classes and Interfaces
Object Oriented Programming in java
Class.
Chapter 3 Introduction to Classes, Objects Methods and Strings
(C) 2010 Pearson Education, Inc. All rights reserved.
Presentation transcript:

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 use the ‘ class declaration ’ to create many objects of that ‘ class type ’

A java class ‘class’ is a keyword every class has a name and body a class can contain methods, member variables and constructors class declaration can be preceded by a modifier – ‘public’ or ‘private’ every class object needs to be instantiated with the ‘ new ’ operator

every java ‘class’ is placed in its own file when java source file (given by.java ) is compiled, a.class file gets created in the bin directory of your project The file with the.class extension in the bin directory is the bytecode for the class.

Declaring a primitive data type: int a; char c; byte b; Instantiating a class object: MyClass mc= new MyClass();

Access modifiers ‘public’ —the field is accessible from all classes. ‘private’ —the field is accessible only within its own class. access modifiers can be applied on both member variables and methods of a class

Difference between ‘class’ and primitive data type you cannot invoke a method on a primitive data type you need to instantiate a class variable after you declare it instantiation is done with new operator new is a keyword here

Difference between a static method and normal method static methods are invoked on the class name normal methods are invoked on the class object

More on variables

More on primitive data types - Initialization

Using ‘String’ objects