JAVA: A Primer. By: Amrita Rajagopal
|
|
- Chrystal Miles
- 5 years ago
- Views:
Transcription
1 JAVA: A Primer By: Amrita Rajagopal 1
2 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently of a browser applet--a Java program to be included in HTML pages and executed in Javaenabled browsers 2
3 Object Oriented Programming Key Features of OOP: 1) Data Abstraction (Encapsulation) 2) Inheritance 3) Polymorphism Discussed in future lectures 3
4 Key Terminology Object: An object is a software bundle of related variables and methods (same as SmallTalk) Methods (Messages): Objects interact and communicate with each other using methods. (same as SmallTalk) Class: A class is a blueprint or prototype that defines the variables and the methods common to all objects of a certain kind (same as SmallTalk) Interface: An interface is a contract in the form of a collection of method and constant declarations. When a class implements an interface, it promises to implement all of the methods declared in that interface. Inheritance: A class inherits state and behavior from its superclass (same as SmallTalk) In Java inheritance is extended to multi-level. Polymorphism: Allows improved code organization and readability as well as the creation of extensible programs that can be grown not only during the original creation of the project, but also when new features are desired. 4
5 Data Abstraction.or Encapsulation: The mechanism that binds together code and the data it manipulates, keeping both safe from outside interference and misuse. In Java, the basis of encapsulation is the class (same as SmallTalk) which is a logical construct; the object being its physical reality. (Discussed ahead) 5
6 The Class revisited A Class is a template for an object, and an object is an instance of a class. A Class describes a set of objects that have identical characteristics and behaviors, a class is really a data type For example: every bank account has a balance, every bank teller can accept a deposit, etc. At the same time, each member has its own state: each account has a different balance, each teller has a name. Thus, the tellers, customers, accounts, transactions, etc., can each be represented with a unique entity in the program. This entity is the object, and each object belongs to a particular class that defines its characteristics and behaviors 6
7 class classname { type instance-var1; type instance-var1; // type instance-varn; General form of a class } return-type method1( paramaters ) { //body of method } return-type method2( paramaters ) { //body of method } // return-type methodn( paramaters ) { //body of method } 7
8 Example: public class Car { //instance variables public char color; public int shade; //member method to change car color public void changecolor(char color, int shade) { this.color = color; this.shade = shade; System.out.print("Car color: " + this.color + ", shade: " + this.shade); } } //... 8
9 Hidden Implementation Implementation Hiding refers to regulating access control. Reasons for implementing access control: To keep client programmers hands off portions they shouldn t touch. To allow the library designer to change the internal workings of the class without worrying about how it will affect the client programmer. To set boundaries in a class the following Access Specifiers are used: public: The element is available to everyone. e.g.: public int a; private: The element is available only to the methods within the class where it was declared. (Same as SmallTalk) e.g.: private int a; protected: The protected keyword acts like private, with the exception that an inheriting class has access to protected members. e.g.: protected int a; 9
10 The this keyword this keyword is used inside methods to refer to the current object. In other words, this refers to the object that invoked the method Example: public class Car { //... } //member method to change car color public void changecolor(char color, int shade) { this.color = color; this.shade = shade; System.out.print("Car color: " + this.color + ", shade: " + this.shade); } 10
11 Notice in the example that the local members and method parameters have the same name. Again, the this keyword is used to distinguish between the local variables and the parameters. this.color refers to the class s instance variable color refers to the parameter. 11
12 Constructors Constructor functions are used to initialize objects after declaration. Constructors are used with the new operator to construct objects of a class type Constructors are class members which have the same name as the class and have no return type. The default constructor is a constructor with no arguments. A constructor with an argument list is a parameterized constructor. Examples of constructor definitions are shown on the following slide. Their usage will be explained ahead. 12
13 public class Car { //instance variables public char color; public int shade; //Constructor functions public Car() //default constructor { color = 'B'; shade = 1; } //parameterized constructor public Car(char color, int shade) { this.color = color; this.shade = shade; } } //... 13
14 Class Fundamentals Summary: A class; as discussed before, defines a new data type. This new type is used to create objects of that type. The variables defined within a class are called instance variables because each instance of the class contains its copy of these variables. Code is contained in methods. Instance variables and methods are members of the class. A class is declared by using the class keyword. Constructor functions are used to initialize objects upon declaration. 14
15 The Object revisited An object is a software bundle of related variables and methods. Software objects are often used to model real-world objects you find in everyday life. (Sun s definition of an object) An object is an instance of a class. An object has state, behavior and identity State internal data Behavior methods Identity each object can be uniquely distinguished from every other object 15
16 Creating Objects There are three aspects to object creation: Declaration declare a variable of the class type which refers to the object. Instantiation Acquire an actual copy of the object and assign it the variable. Initialization Initialize the object using constructors. (or) classname var = new classname(); classname var; var = new classname(); These two statement blocks are equivalent. First we declare the variable as a reference to an object of the particular class-type. The new keyword assigns an actual object and references it to the declared variable. The classname which follows the new keyword, actually refers to the constructor functions of the class. This part can include parameters if there exists a constructor function which requires parameters. 16
17 Examples: Consider the class Car again for the following declarations. Car c1 = new Car(); (or) Car c1; c1 = new Car(); Both object declarations are equivalent. They call class Car s default constructor. Therefore, the values of c1 s instance variables are: c1.color = B, c1.shade = 1. Car c1 = new Car('R', 2); (or) Car c1; c1 = new Car('R', 2); In this case, the objects are initialized using the parameterized constructor. So the instance variable values for c1 are: c1.color = R, c1.shade = 2. 17
18 The new keyword Consider the following segment: Car c1 = new Car(); The new operator dynamically allocates memory for an object and returns a reference to it. This reference gives the memory address of the object which is in turn stored in the variable. In the above case, new assigns memory for an object of type Car and returns the reference which is stored in variable c1. 18
19 Object References Lets refer back to class Car. Consider the following statements: Car c1 = new Car( ); Car c2; c2 = c1; Here c1 and c2 do not refer to separate objects. c1 and c2 actually refer to the same object. There is no allocation of new memory. But, though c1 and c2 refer to the same object, they are not linked in any way. c1 = null; c1 becomes null but c2 still points to the original object. 19
20 Thinking in JAVA Before we start writing JAVA programs lets go over some features of object oriented programming required to write efficient applications. SmallTalk was the first successful object oriented language and JAVA was built on its characteristics. Alan Kay (inventor of SmallTalk) put forth the following 5 guidelines for object-oriented programming: 1. Everything is an object. You can take any conceptual component in the problem you re trying to solve and represent it as an object in your program. 2. A program is a bunch of objects telling each other what to do by sending messages. Think of a message as a request to call a method that belongs to a particular object. 3. Each object has its own memory made up of other objects. Put another way, you create a new kind of object by making a package containing existing objects. Thus, you can build complexity into a program while hiding it behind the simplicity of objects. 20
21 Thinking in JAVA 4. Every object has a type. Each object is an instance of a class, in which class is synonymous with type. 5. All objects of a particular type can receive the same messages. This is actually a loaded statement, as you will see later. Because an object of type circle is also an object of type shape, a circle is guaranteed to accept shape messages. This means you can write code that talks to shapes and automatically handle anything that fits the description of a shape. This substitutability is one of the powerful concepts in OOP. 21
22 Program elements Some final notes before we start with a very simple JAVA program. The basic structure of a JAVA program is similar to a SmallTalk program Data or variables defined within a class are called instance variables. Code is contained within methods. Variables and methods constitute the class. Important Note: A JAVA application must have a main method. The main method is treated as the entry point for execution. 22
23 Kickoff: Your first program in JAVA /* HelloWorld.java Code for the HelloWorld application */ import java.lang.*; public class HelloWorld { //importing basic language //functions in the java package //class HelloWorld public static void main(string[ ] args) //main function { System.out.print("Hello world! This is my first JAVA program!"); //display the String } } //end class HelloWorld 23
24 Compiling & Execution ECE208, ECE226 Write your JAVA program using TextPad. Make sure to save the file with a.java extension To compile the program go to Tools -> Compile JAVA (or) press CTRL+1 To run the program after compilation go to Tools -> Run JAVA application (or) press CTRL+2 The output is visible in a terminal window which opens up on execution. From home Download TextPad: JAVA SDK: 24
25 Program Analysis - Comments in JAVA code /* text */ The compiler ignores everything from /* to */. /** documentation */ This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and */ (The Java Developers Kit s javadoc tool uses doc comments when preparing automatically generated documentation) // text The compiler ignores everything from // to the end of the line. 25
26 Program Analysis - Importing Packages A package is a collection of related classes and interfaces providing access protection and namespace management. In JAVA, packages are stored in a hierarchical manner (in the java package) and are explicitly imported into new class definitions. Syntax for importing packages: import pckg1[.pckg2].(classname/*); For example: import java.util.*; Example classes: Date, Arrays, Stack, LinkedList import java.lang.math; Example methods: abs( ), exp( ), floor( ), pow( ) Other packages: javax.swing.*; java.awt.* etc. Complete class reference: 26
27 Importing Packages (Contd ) Basic class functions are stored in the package java.lang. This package is implicitly imported by the compiler for all programs. So the following line can be omitted from the HelloWorld.java program: import java.lang.*; Additional classes need to be imported at the beginning of the program. 27
28 Program Analysis Naming convention In JAVA, all the code resides inside a class. By convention the class s name should match the name of the file that holds the program Hence, for the HelloWorld class, the filename has to be HelloWorld.java Note: In JAVA, { } braces are used to define a block of code for classes, methods and local scopes 28
29 Program Analysis The main method Every Java application must contain a main method as this is the line at which the program will begin executing. public static void main(string[ ] args) public indicates that the main method can be accessed by code outside the class in which it id declared. static (discussed ahead) void indicates that the main method doesn't return any value. The main method accepts a single argument: an array of type String. This array is the mechanism through which the runtime system passes information to your application. (command-line arguments) 29
30 Program Analysis Static keyword A class normally doesn t have physical existence unless its object is initialized. The static keyword implies that data or method is not tied to any particular object instance of a class. So even if you ve never created an object of that class you can call a static method or access a piece of static data. With ordinary, non-static data and methods, you must create an object and use that object to access the data or method, since non-static data and methods must know the particular object they are working with 30
31 Program Analysis System class The following code prints the string Hello world! This is my first JAVA program! on the screen. System.out.print("Hello world! This is my first JAVA program!"); System is a predefined class that represents the system on which the program executes. out is an object reference to a PrintStream object that represents standard output. PrintStream is a class with a method called print( ) which prints a string to the standard output. In this case, standard output is the terminal screen. 31
32 Summing up. What we learnt so far: Key features of OOP Thinking in JAVA Basic program structure Looking Ahead:- A Little JAVA: A quick programming reference Inheritance and Polymorphism Program Development Case Study Java Database Connectivity 32
OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationOOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.
OOPs Concepts 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8. Type Casting Let us discuss them in detail: 1. Data Hiding: Every
More informationCS6301 PROGRAMMING AND DATA STRUCTURES II QUESTION BANK UNIT-I 2-marks ) Give some characteristics of procedure-oriented language. Emphasis is on doing things (algorithms). Larger programs are divided
More informationData Structures using OOP C++ Lecture 3
References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.
More informationIntroduction to Object-Oriented Programming
Introduction to Object-Oriented Programming Objects and classes Abstract Data Types (ADT). Encapsulation OOP: Introduction 1 Pure Object-Oriented Languages Five rules [Source: Alan Kay]: Everything in
More informationObject-Oriented Programming Concepts
Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are
More informationJava Professional Certificate Day 1- Bridge Session
Java Professional Certificate Day 1- Bridge Session 1 Java - An Introduction Basic Features and Concepts Java - The new programming language from Sun Microsystems Java -Allows anyone to publish a web page
More informationChapter Two Bonus Lesson: JavaDoc
We ve already talked about adding simple comments to your source code. The JDK actually supports more meaningful comments as well. If you add specially-formatted comments, you can then use a tool called
More informationObject Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year
Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures
More informationCS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes
CS111: PROGRAMMING LANGUAGE II Lecture 1: Introduction to classes Lecture Contents 2 What is a class? Encapsulation Class basics: Data Methods Objects Defining and using a class In Java 3 Java is an object-oriented
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 and Interfaces
Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationSri Vidya College of Engineering & Technology
UNIT I INTRODUCTION TO OOP AND FUNDAMENTALS OF JAVA 1. Define OOP. Part A Object-Oriented Programming (OOP) is a methodology or paradigm to design a program using classes and objects. It simplifies the
More informationClasses. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).
UNITII Classes Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). It s a User Defined Data-type. The Data declared in a Class are called Data- Members
More information9 Working with the Java Class Library
9 Working with the Java Class Library 1 Objectives At the end of the lesson, the student should be able to: Explain object-oriented programming and some of its concepts Differentiate between classes and
More informationSTUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationC++ & Object Oriented Programming Concepts The procedural programming is the standard approach used in many traditional computer languages such as BASIC, C, FORTRAN and PASCAL. The procedural programming
More informationLecture 6 Introduction to Objects and Classes
Lecture 6 Introduction to Objects and Classes Outline Basic concepts Recap Computer programs Programming languages Programming paradigms Object oriented paradigm-objects and classes in Java Constructors
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationChapter 14 Abstract Classes and Interfaces
Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden
More informationWhat is Inheritance?
Inheritance 1 Agenda What is and Why Inheritance? How to derive a sub-class? Object class Constructor calling chain super keyword Overriding methods (most important) Hiding methods Hiding fields Type casting
More informationObject Oriented Programming
Object Oriented Programming Digital Urban Visualization. People as Flows. 10.10.2016 ia zuend@arch.ethz.ch treyer@arch.ethz.ch chirkin@arch.ethz.ch Object Oriented Programming? Pertaining to a technique
More informationLecture 7: Classes and Objects CS2301
Lecture 7: Classes and Objects NADA ALZAHRANI CS2301 1 What is OOP? Object-oriented programming (OOP) involves programming using objects. An object represents an entity in the real world that can be distinctly
More informationOutline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring
Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,
More informationOBJECT ORİENTATİON ENCAPSULATİON
OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCS260 Intro to Java & Android 02.Java Technology
CS260 Intro to Java & Android 02.Java Technology CS260 - Intro to Java & Android 1 Getting Started: http://docs.oracle.com/javase/tutorial/getstarted/index.html Java Technology is: (a) a programming language
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationJava Basics. Object Orientated Programming in Java. Benjamin Kenwright
Java Basics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Java Concepts Syntax, Grammar, Formatting, Introduce Object-Orientated Concepts Encapsulation, Abstract Data, OO Languages,
More informationSoftware Design and Analysis for Engineers
Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:
More informationPackages & Random and Math Classes
Packages & Random and Math Classes Quick review of last lecture September 6, 2006 ComS 207: Programming I (in Java) Iowa State University, FALL 2006 Instructor: Alexander Stoytchev Objects Classes An object
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationProgramming overview
Programming overview Basic Java A Java program consists of: One or more classes A class contains one or more methods A method contains program statements Each class in a separate file MyClass defined in
More informationJava OOP (SE Tutorials: Learning the Java Language Trail : Object-Oriented Programming Concepts Lesson )
Java OOP (SE Tutorials: Learning the Java Language Trail : Object-Oriented Programming Concepts Lesson ) Dongwon Jeong djeong@kunsan.ac.kr; http://ist.kunsan.ac.kr/ Information Sciences and Technology
More informationObject Orientated Analysis and Design. Benjamin Kenwright
Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More information2 rd class Department of Programming. OOP with Java Programming
1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach
More informationAfter a lecture on cosmology and the structure of the solar system, William James was accosted by a little old lady.
Introduction After a lecture on cosmology and the structure of the solar system, William James was accosted by a little old lady. Your theory that the sun is the centre of the solar system, and the earth
More informationCOMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal
COMSC-051 Java Programming Part 1 Part-Time Instructor: Joenil Mistal Chapter 4 4 Moving Toward Object- Oriented Programming This chapter provides a provides an overview of basic concepts of the object-oriented
More informationObject-Oriented Programming
Object-Oriented Programming In C++ classes provide the functionality necessary to use object-oriented programming OOP is a particular way of organizing computer programs It doesn t allow you to do anything
More information12/22/11. Java How to Program, 9/e. public must be stored in a file that has the same name as the class and ends with the.java file-name extension.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Covered in this chapter Classes Objects Methods Parameters double primitive type } Create a new class (GradeBook) } Use it to create an object.
More informationData Abstraction. Hwansoo Han
Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationOutline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003
Outline Object Oriented Programming Autumn 2003 2 Course goals Software design vs hacking Abstractions vs language (syntax) Java used to illustrate concepts NOT a course about Java Prerequisites knowledge
More informationLecture 18 Tao Wang 1
Lecture 18 Tao Wang 1 Abstract Data Types in C++ (Classes) A procedural program consists of one or more algorithms that have been written in computerreadable language Input and display of program output
More informationJava How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;
More informationThe object-oriented approach goes a step further by providing tools for the programmer to represent elements in the problem space.
1 All programming languages provide abstractions. Assembly language is a small abstraction of the underlying machine. Many imperative languages (FORTRAN, BASIC, and C) are abstractions of assembly language.
More informationUnit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW
Prepared by: Dr. Abdallah Mohamed, AOU-KW 1 1. Introduction 2. Objects and classes 3. Information hiding 4. Constructors 5. Some examples of Java classes 6. Inheritance revisited 7. The class hierarchy
More informationJava Libraries. Lecture 6 CGS 3416 Fall September 21, 2015
Java Libraries Lecture 6 CGS 3416 Fall 2015 September 21, 2015 Intro to Libraries We ve barely scratched the surface of Java, but before we proceed with programming concepts, we need to talk about the
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More informationDepartment of Computer science and Engineering Sub. Name: Object oriented programming and data structures Sub. Code: EC6301 Sem/Class: III/II-ECE Staff name: M.Kavipriya Two Mark Questions UNIT-1 1. List
More informationClasses - 2. Data Processing Course, I. Hrivnacova, IPN Orsay
Classes - 2 Data Processing Course, I. Hrivnacova, IPN Orsay OOP, Classes Reminder Requirements for a Class Class Development Constructor Access Control Modifiers Getters, Setters Keyword this const Member
More informationMethods (Deitel chapter 6)
Methods (Deitel chapter 6) 1 Plan 2 Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
More informationMethods (Deitel chapter 6)
1 Plan 2 Methods (Deitel chapter ) Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
More informationLecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction
Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO
More informationCOMP 250 Winter 2011 Reading: Java background January 5, 2011
Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP
More informationJava Fundamentals (II)
Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class
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 informationCS 251 INTERMEDIATE SOFTWARE DESIGN SPRING C ++ Basics Review part 2 Auto pointer, templates, STL algorithms
CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 C ++ Basics Review part 2 Auto pointer, templates, STL algorithms AUTO POINTER (AUTO_PTR) //Example showing a bad situation with naked pointers void MyFunction()
More informationDay 4. COMP1006/1406 Summer M. Jason Hinek Carleton University
Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information
More information1/29/2011 AUTO POINTER (AUTO_PTR) INTERMEDIATE SOFTWARE DESIGN SPRING delete ptr might not happen memory leak!
//Example showing a bad situation with naked pointers CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 C ++ Basics Review part 2 Auto pointer, templates, STL algorithms void MyFunction() MyClass* ptr( new
More informationClasses, subclasses, subtyping
1 CSCE 314: Programming Languages Dr. Flemming Andersen Classes, subclasses, subtyping 2 3 Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that one
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationPreview from Notesale.co.uk Page 3 of 36
all people who know the language. Similarly, programming languages also have a vocabulary, which is referred to as the set of keywords of that language, and a grammar, which is referred to as the syntax.
More informationCS-202 Introduction to Object Oriented Programming
CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction
More informationUnit 4 - Inheritance, Packages & Interfaces
Inheritance Inheritance is the process, by which class can acquire the properties and methods of its parent class. The mechanism of deriving a new child class from an old parent class is called inheritance.
More informationA student was asked to point out interface elements in this code: Answer: cout. What is wrong?
A student was asked to point out interface elements in this code: Answer: cout. What is wrong? Clarification of the concept of INTERFACE The interface we ve been talking about in OOP is not the man-machine
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More information1: Introduction to Object (1)
1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface
More informationPROGRAMMING IN C++ COURSE CONTENT
PROGRAMMING IN C++ 1 COURSE CONTENT UNIT I PRINCIPLES OF OBJECT ORIENTED PROGRAMMING 2 1.1 Procedure oriented Programming 1.2 Object oriented programming paradigm 1.3 Basic concepts of Object Oriented
More informationFundamentals of Object Oriented Programming
INDIAN INSTITUTE OF TECHNOLOGY ROORKEE Fundamentals of Object Oriented Programming CSN- 103 Dr. R. Balasubramanian Associate Professor Department of Computer Science and Engineering Indian Institute of
More informationCSCI 253. Outline. Background. George Blankenship 1
CSCI 253 Object Oriented Design: Object Oriented Design and Programming in Java George Blankenship George Blankenship 1 Outline Background Rationale for the course Why object oriented programming? OOP
More informationAtelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.
marwan.burelle@lse.epita.fr http://wiki-prog.kh405.net Plan 1 2 Plan 3 4 Plan 1 2 3 4 A Bit of History JAVA was created in 1991 by James Gosling of SUN. The first public implementation (v1.0) in 1995.
More information7. C++ Class and Object
7. C++ Class and Object 7.1 Class: The classes are the most important feature of C++ that leads to Object Oriented programming. Class is a user defined data type, which holds its own data members and member
More informationIndustrial Programming
Industrial Programming Lecture 4: C# Objects & Classes Industrial Programming 1 What is an Object Central to the object-oriented programming paradigm is the notion of an object. Objects are the nouns a
More informationWhat is an Object. Industrial Programming. What is a Class (cont'd) What is a Class. Lecture 4: C# Objects & Classes
What is an Object Industrial Programming Lecture 4: C# Objects & Classes Central to the object-oriented programming paradigm is the notion of an object. Objects are the nouns a person called John Objects
More informationEEE-425 Programming Languages (2013) 1
2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationD Programming Language
Group 14 Muazam Ali Anil Ozdemir D Programming Language Introduction and Why D? It doesn t come with a religion this is written somewhere along the overview of D programming language. If you actually take
More informationAdvantages of Object Oriented Programming :- Features of Object Oriented Programming :- Advantages Of Object Oriented Programming :
Advantages of Object Oriented Programming :- 1. Exploits the expressive power of all object oriented programming languages. 2. Encourages the resuse of software components. 3. Leads to the systems that
More informationG Programming Languages Spring 2010 Lecture 9. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 9 Robert Grimm, New York University 1 Review Last week Modules 2 Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic
More informationSoftware Paradigms (Lesson 3) Object-Oriented Paradigm (2)
Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3
More informationAgenda. Objects and classes Encapsulation and information hiding Documentation Packages
Preliminaries II 1 Agenda Objects and classes Encapsulation and information hiding Documentation Packages Inheritance Polymorphism Implementation of inheritance in Java Abstract classes Interfaces Generics
More informationThe Essence of OOP using Java, Nested Top-Level Classes. Preface
The Essence of OOP using Java, Nested Top-Level Classes Baldwin explains nested top-level classes, and illustrates a very useful polymorphic structure where nested classes extend the enclosing class and
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba Laboratory Session: Exercises on classes Analogy to help you understand classes and their contents. Suppose you want to drive a car and make it go faster by pressing down
More informationJava Intro 3. Java Intro 3. Class Libraries and the Java API. Outline
Java Intro 3 9/7/2007 1 Java Intro 3 Outline Java API Packages Access Rules, Class Visibility Strings as Objects Wrapper classes Static Attributes & Methods Hello World details 9/7/2007 2 Class Libraries
More informationJava. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)
Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu
More informationBasic Principles of OO. Example: Ice/Water Dispenser. Systems Thinking. Interfaces: Describing Behavior. People's Roles wrt Systems
Basics of OO Programming with Java/C# Basic Principles of OO Abstraction Encapsulation Modularity Breaking up something into smaller, more manageable pieces Hierarchy Refining through levels of abstraction
More informationThe Java Programming Language
The Java Programming Language Slide by John Mitchell (http://www.stanford.edu/class/cs242/slides/) Outline Language Overview History and design goals Classes and Inheritance Object features Encapsulation
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationpublic class Foo { private int var; public int Method1() { // var accessible anywhere here } public int MethodN() {
Scoping, Static Variables, Overloading, Packages In this lecture, we will examine in more detail the notion of scope for variables. We ve already indicated that variables only exist within the block they
More informationOops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:
Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Abstraction Encapsulation Inheritance and Polymorphism Object-Oriented
More informationDefining Classes and Methods
Defining Classes and Methods Chapter 4 Chapter 4 1 Basic Terminology Objects can represent almost anything. A class defines a kind of object. It specifies the kinds of data an object of the class can have.
More informationIndex. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions
Index Course Outline Grading Policy Lab Time Distribution Important Instructions 2 Course Outline Week Topics 1 - History and Evolution of Java - Overview of Java 2 - Datatypes - Variables 3 - Arrays 4
More information