By: Abhishek Khare (SVIM - INDORE M.P)

Size: px
Start display at page:

Download "By: Abhishek Khare (SVIM - INDORE M.P)"

Transcription

1 By: Abhishek Khare (SVIM - INDORE M.P) MCA 405 Elective I (A) Java Programming & Technology

2 UNIT-I The Java Environment, Basics, Object Oriented Programming in Java, Inheritance The Java Environment: History of Java: Comparison of Java and C++ Java as an object oriented language: Java buzzwords A simple program, its compilation and execution; the concept of CLASSPATH Basic idea of application and applet Basics: Data types; Operators- precedence and associativity; Type conversion The decision making if, if..else, switch; loops for, while, do while special statements return, break, continue, labeled break, labeled continue Modular programming methods; arrays; memory allocation and garbage collection in java keywords. Object Oriented Programming in Java: Class; Packages; scope and lifetime; Access specifies Constructors; Copy constructor; this pointer finalize () method Inheritance : Inheritance basics, method overriding, dynamics method dispatch, abstract classes. 2

3 Java started out as a research project Research began in 1991 as the Green Project Project was chartered to anticipate and plan for next wave of computing Green Team determined consumer devices and computers would converge Team focused on TV set-top boxes and interactive TV industries Research efforts birthed a new language, OAK Created by James Gosling - the father of Java Language was created with 5 main goals: 1. It should be object oriented 2. A single representation of a program could be executed on multiple operating systems 3. It should fully support network programming 4. It should execute code from remote sources securely 5. It should be easy to use Oak was renamed Java in

4 4

5 Java as an object oriented language: Java buzzwords Simple and Powerful Object Oriented Portable Architecture Neutral Distributed Multi-threaded Robust, Secure/Safe Interpreted High Performance Dynamic programming language/platform. 5

6 How to compile and run java programs? Write Once, Run Anywhere 6

7 Download and Install JDK (Java Development Kit) Download the latest version of jdk from Once you download the exe file you can now install it. Double Click the icon of downloaded exe. 7

8 The concept of PATH, CLASSPATH, JAVA_HOME In PATH Environment variable you need to specify only.exe (Executable files that Operating System Uses). In CLASSPATH environment you need to specify only.class files i.e. you are helping Java Virtual Machine (JVM) to find Java class files Note: For running java application you need to set PATH alone. For versions above jdk 1.5, JAVA_HOME itself is enough. No need to set CLASSPATH. Variable name: JAVA_HOME Variable value: C:\Program Files\Java\jdk1.6.0_11 Variable name: PATH Variable value: %PATH%;%JAVA_HOME%\bin 8

9 What is the meaning of PATH and CLASSPATH? How it is set in environment variable? PATH variable on command prompt C:\>set path=%path;c:\java\jdk1.6.0_03\bin% CLASSPATH variable on command prompt C:\>set classpath=%classpath;c:\java\jdk1.6.0_03\lib% 9

10 10

11 An overview of the software development process. 1. All source code is first written in plain text files ending with the.java extension 2. Those source files are then compiled into.class files by the javac compiler. 3. A.class file does not contain code that is native to your processor; it instead contains bytecodes. 4. Bytecodes are the machine language of the Java Virtual Machine (JVM). 5. The java launcher tool then runs your application with an instance of the Java Virtual Machine. 11

12 How to run java program? Step 1 Coding Create a text file Hello.java and copy below contents. public class FirstHello { public static void main(string[] args) { System.out.println("Hello Java"); Step 2 - Deployment 1. Create a folder 'c:\javaprograms'. 2. Create or copy Hello.java into 'c:\javaprograms' folder. 3. Open your command prompt and go to 'c:\javaprograms' 4. Compile Hello.java with help of javac Hello.java command. Command will create class file in the same folder. Congratulations!! your First Java program is ready to serve. 12

13 Step 3 - Testing 1. Make sure you are on Command Prompt under c:\javaprograms directory 2. Now start your First java program from command prompt with help of java Hello command. Output It will show a message. Hello java... Error : C:\javaprograms>javac FirstHello.java 'javac' is not recognized as an internal or external command, operable program or batch file. Resolution : Check your PATH environment variable. JAVA_HOME is not in PATH. Set path by SET PATH=%JAVA_HOME%/bin;%PATH% 13

14 Basic idea of application and applet We can develop two types of Java Programs: 1. Java Application 2. Web Applets Applets are the small programs while applications are larger programs. Applets don't have the main method while in an application execution starts with the main method. Applets can run in our browser's window or in an appletviewer while applications run on command prompt. Applets are designed just for handling the client site problems. while the java applications are designed to work with the client as well as server. 14

15 Basics: Data types; Operators- precedence and associativity; Type conversion There are two data types available in Java: 1. Primitive Data Types 2. Reference/Object Data Types Primitive Data Types: There are eight primitive data types supported by Java. 1. byte: 1. Byte data type is a 8-bit signed integer. 2. Minimum value is -128 (-2^7) 3. Maximum value is 127 (inclusive)(2^7-1) 4. Default value is 0 5. Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int. Example : byte a = 100, byte b =

16 2. short: 1. Short data type is a 16-bit signed integer. 2. Minimum value is -32,768 (-2^15) 3. Maximum value is 32,767(inclusive) (2^15-1) 4. Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int 5. Default value is 0. Example : short s= 10000, short r = int: 1. Int data type is a 32-bit signed integer. 2. Minimum value is - 2,147,483,648.(-2^31) 3. Maximum value is 2,147,483,647(inclusive).(2^31-1) 4. Int is generally used as the default data type for integral values unless there is a concern about memory. 5. The default value is 0. Example : int a = , int b = long: 1. Long data type is a 64-bit signed integer. 2. Minimum value is -9,223,372,036,854,775,808.(-2^63) 3. Maximum value is 9,223,372,036,854,775,807 (inclusive). (2^63-1) 4. This type is used when a wider range than int is needed. 5. Default value is 0L. Example : int a = L, int b = L 16

17 5. float: 1. Float data type is a single-precision 32-bit IEEE 754 floating point. 2. Float is mainly used to save memory in large arrays of floating point numbers. 3. Default value is 0.0f. 4. Float data type is never used for precise values such as currency. Example : float f1 = 234.5f 6. double: 1. double data type is a double-precision 64-bit IEEE 754 floating point. 2. This data type is generally used as the default data type for decimal values. generally the default choice. 3. Double data type should never be used for precise values such as currency. 4. Default value is 0.0d. Example : double d1 = boolean: 1. boolean data type represents one bit of information. 2. There are only two possible values : true and false. 3. This data type is used for simple flags that track true/false conditions. 4. Default value is false. Example : boolean one = true 8. char: 1. char data type is a single 16-bit Unicode character. 2. Minimum value is '\u0000' (or 0). 3. Maximum value is '\uffff' (or 65,535 inclusive). 4. Char data type is used to store any character. Example. char lettera ='A' 17

18 Reference Data Types: Reference variables are created using defined constructors of the classes. They are used to access objects. These variables are declared to be of a specific type that cannot be changed. For example, Employee, Credit_card etc. Class objects, and various type of array variables come under reference data type. Default value of any reference variable is null. A reference variable can be used to refer to any object of the declared type or any compatible type. Example : Animal animal = new Animal("giraffe"); 18

19 variables in Java There are three kinds of variables in Java: 1. Local variables 2. Instance variables 3. Class/static variables Local variables : 1. Local variables are declared in methods, constructors, or blocks. 2. Local variables are created when the method, constructor or block is entered and the variable will be destroyed once it exits the method, constructor or block. 3. Access modifiers cannot be used for local variables. 4. Local variables are visible only within the declared method, constructor or block. 5. Local variables are implemented at stack level internally. 6. There is no default value for local variables so local variables should be declared and an initial value should be assigned before the first use. 19

20 Instance variables : 1. Instance variables are declared in a class, but outside a method, constructor or any block. 2. When a space is allocated for an object in the heap a slot for each instance variable value is created. 3. Instance variables are created when an object is created with the use of the key word 'new' and destroyed when the object is destroyed. The difference between instance and local variables 20

21 Class/static variables : 1. Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block. 2. There would only be one copy of each class variable per class, regardless of how many objects are created from it. 21

22 class Circle1 { static int num_circles = 0; // class variable: how many circles created public double x, y, r; radius // instance vars: the center and the public Circle1(double x, double y, double r) { this.x = x; this.y = y; this.r = r; num_circles++; public Circle1(double r) { this(0.0, 0.0, r); public Circle1(Circle1 c) { this(c.x, c.y, c.r); public Circle1() { this(0.0, 0.0, 1.0); public double circumference() { return 2 * * r; public double area() { return * r*r; public class Circle { public static void main(string[] args) { Circle1 C1=new Circle1(2); Circle1 C2=new Circle1(C1); Circle1 C3=new Circle1(); System.out.println("Number of circles created: " + Circle1.num_circles); System.out.println("Number of circles created: " + C1.area()); System.out.println("Number of circles created: " + C1.circumference()); 22

23 23

24 What are Methods? A method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method's name. Think of a method as a subprogram that acts on data and often returns a value. There are two basic types of methods: Built-in: Build-in methods are part of the compiler package, such as System.out.println( ) and System.exit(0). User-defined: User-defined methods are created by you, the programmer. These methods take-on names that you assign to them and perform tasks that you create. 24

25 // Demonstrate method overloading. class OverloadDemo { void test() { System.out.println("No parameters"); // Overload test for one integer parameter. void test(int a) { System.out.println("a: " + a); // Overload test for two integer parameters. void test(int a, int b) { System.out.println("a and b: " + a + " " + b); // overload test for a double parameter double test(double a) { System.out.println("double a: " + a); return a*a; public class Overload { public static void main(string args[]) { OverloadDemo ob = new OverloadDemo(); double result; // call all versions of test() ob.test(); ob.test(10); ob.test(10, 20); result = ob.test(123.2); System.out.println("Result of ob.test(123.2): " + result); Method overloading 25

26 arrays; memory allocation and garbage collection in java keywords The java array enables the user to store the values of the same type in contiguous memory allocations. Arrays are always a fixed length abstracted data structure which can not be altered when required. public class Sum { public static void main(string[] args) { int[] x = new int [101]; for (int i = 0; i<x.length; i++ ) x[i] = i; int sum = 0; for(int i = 0; i<x.length; i++) sum += x[i]; System.out.println(sum); 26

27 Multi-dimensional arrays A 2-D Array is really an Array of Arrays Syntax: int[ ][ ] nums = new int[5][4] The above is really equivalent to a 3-step process: // create the single reference nums (yellow square) int [][] nums; // create the array of references (blue squares) nums = new int[5][]; // this create the second level of arrays (red squares) for (int i=0; i < 5 ; i++) nums[i] = new int[4]; // create arrays of integers 27

28 public class twod { public static void main(string [] args) { int [][] a={{1,{2,3,{4,5,6,{7,8,9,10; for(int i=0;i<a.length;i++) { for(int j=0;j<a[i].length;j++) { System.out.print(" "+a[i][j]); System.out.println("\tLength of"+i+"row is :"+a[i].length); System.out.println(); 28

29 Garbage Collection in Java 1) objects are created on heap in Java irrespective of there scope e.g. local or member variable. while its worth noting that class variables or static members are created in method area of Java memory space and both heap and method area is shared between different thread. 2) Garbage collection is a mechanism provided by Java Virtual Machine to reclaim heap space from objects which are eligible for Garbage collection. 3) Garbage Collection in Java is carried by a daemon thread called Garbage Collector. 4) Before removing an object from memory Garbage collection thread invokes finalize () method of that object and gives an opportunity to perform any sort of cleanup required. 5) You as Java programmer can not force Garbage collection in Java; it will only trigger if JVM thinks it needs a garbage collection based on Java heap size. 6) There are methods like System.gc () and Runtime.gc () which is used to send request of Garbage collection to JVM but it s not guaranteed that garbage collection will happen. 7) 8) If there is no memory space for creating new object in Heap Java Virtual Machine throws OutOfMemoryError or java.lang.outofmemoryerror heap space 29

30 Understanding of main function of java class two { static int i; static int geti() { return i; public class twodd { static int j; public static void main(string [] args) { two t=new two(); System.out.println("value is:"+t.geti()+j); 30

31 Command Line Argument class Demo { public static void main(string [ ] args) { System.out.println("Argument one = "+args[0]); System.out.println("Argument two = "+args[1]); args.length 31

32 Packages Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier etc. A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and name space management. Some of the existing packages in Java are:: java.lang - bundles the fundamental classes java.io - classes for input, output functions are bundled in this package Creating a package: 32

33 The package statement should be the first line in the source file. There can be only one package statement in each source file, and it applies to all types in the file. If a package statement is not used then the class, interfaces, enumerations, and annotation types will be put into an unnamed package. package p1; class c1{ public void m1() { System.out.println("Method m1 of Class c1"); public static void main(string args[]){ c1 obj = new c1(); obj.m1(); Step 1) Save the file as Demo.java. Compile the file as, javac d. Demo.java Step 2) Run the code as java p1.c1 33

34 How to use packages set CLASSPATH=.;C:\; Importing a package To create an object of a class (bundled in a package), in your code, you have to use its fully qualified name. // Using packages created in earlier assignment package p3; import p1.*; //imports classes of package p1 class c3{ public void m3(){ System.out.println("Method m3 of Class c3"); public static void main(string args[]){ c1 obj1 = new c1(); obj1.m1(); c3 obj2 = new c3(); obj2.m3(); 34

35 package p1; public class c1 { public void m1() { System.out.println("Method m1 of class c1"); 35

36 Access Modifiers/ Specifier 1. public 2. private 3. protected 4. default Default: 1. Default access modifier is no-modifier. i.e. when you do not specify any access modifier explicitly for a method, a variable or a class 2. Default access also means package-level access. 3. That means a default member can be accessed only inside the same package in which the member is declared. Protected: 1. Protected access modifier is the a little tricky and you can say is a superset of the default access modifier. 2. Protected members are same as the default members as far as the access in the same package is concerned. 3. protected members are accessible outside the package only through inheritance. 36

37 Access Modifier -> Access Location default(none) protected public private Same class YES YES YES YES Subclass in same package Other class in same package Subclass in other packages Non-subclasses in other packages YES YES YES NO YES YES YES NO NO YES YES NO NO NO YES NO 37

38 Constructors; Copy constructor; this pointer Constructor is a special method in java. The purpose of the constructor is to assign initial values to the instance variable of the class. Constructor is always called by new operator. Constructors are declared just like as we declare methods, except that the constructors don t have any return type. Since constructors are called by JVM at runtime during object instantiation so it does not required any return value. Default constructor does not require any parameter. It is called default constructor only because it does not receive any parameter. If the parameters are passed in the constructor then it will no longer be a default constructor 38

39 The this Keyword Sometimes a method will need to refer to the object that invoked it. To allow this, Java defines the this keyword. this can be used inside any method to refer to the current object. this is always a reference to the object on which the method was invoked. public Circle1(double x, double y, double r) { this.x = x; this.y = y; this.r = r; 39

40 Constructor Overloading class Circle1 { static int num_circles = 0; // class variable: how many circles created public double x, y, r; // instance vars: the center and the radius public Circle1(double x, double y, double r) { this.x = x; this.y = y; this.r = r; num_circles++; public Circle1(double r) { this(0.0, 0.0, r); public Circle1(Circle1 c) { this(c.x, c.y, c.r); public Circle1() { this(0.0, 0.0, 1.0); public double circumference() { return 2 * * r; public double area() { return * r*r; 40

41 The finalize( ) Method Sometimes an object will need to perform some action when it is destroyed. Example: If an object is holding some non-java resource such as a file handle. Java provides a mechanism called finalization. By using finalization, you can define specific actions that will occur when an object is just about to be reclaimed by the garbage collector. The finalize( ) method has this general form: protected void finalize( ) { // finalization code here Here, the keyword protected is a specifier that prevents access to finalize( ) by code defined outside its class. 41

42 Inheritance in Java Inheritance is a compile-time mechanism in Java that allows you to extend a class (called the base class or superclass) with another class (called the derived class or subclass). 1. class inheritance create a new class as an extension of another class, primarily for the purpose of code reuse. That is, the derived class inherits the public methods and public data of the base class. Java only allows a class to have one immediate base class, i.e., single class inheritance. 2. interface inheritance create a new class to implement the methods defined as part of an interface for the purpose of subtyping. Java supports multiple interface inheritance. 42

43 Example of class inhertiance package MyPackage; class Base { private int x; public int f() {... protected int g() {... class Derived extends Base { private int y; public void h() { y = g();... 43

44 Super Keyword super has two general forms The first calls the superclass constructor. The second is used to access a member of the superclass that has been hidden by a member of a subclass. super( ) must always be the first statement executed inside a subclass constructor. A subclass can call a constructor defined by its superclass by use of the following form of super: super(arg-list); class BoxWeight extends Box { double weight; // weight of box // initialize width, height, and depth using super() BoxWeight(double w, double h, double d, double m) { super(w, h, d); // call superclass constructor weight = m; 44

45 A Second Use for super The second form of super acts somewhat like this, except that it always refers to the superclass of the subclass in which it is used. This usage has the following general form: super.member Here, member can be either a method or an instance variable. What is the difference between super keyword and this keyword? This second form of super is most applicable to situations in which member names of a subclass hide members by the same name in the superclass. 45

46 Abstract Base Classes An abstract class is a class that leaves one or more method implementations unspecified by declaring one or more methods abstract. An abstract method has no body (i.e., no implementation). A subclass is required to override the abstract method and provide an implementation. Hence, an abstract class is incomplete and cannot be instantiated, but can be used as a base class. abstract public class abstract-base-class-name { // abstract class has at least one abstract method public abstract return-type abstract-method-name ( formal-params );... // other abstract methods, object methods, class methods public class derived-class-name extends abstract-base-class-name { public return-type abstract-method-name (formal-params) { stmt-list;... // other method implementations It would be an error to try to instantiate an object of an abstract type: abstract-class-name obj = new abstract-class-name(); // ERROR! That is, operator new is invalid when applied to an abstract class. 46

47 Interfaces An abstract class mixes the idea of mutable data in the form of instance variables, non-abstract methods, and abstract methods. An abstract class with only static final instance variables and all abstract methods is called an interface. The class that implements the interface provides an implementation for each method, just as with an abstract method in an abstract class. All methods declared in an interface are implicitly abstract and implicitly public You can define data in an interface, but it is less common to do so. If there are data fields defined in an interface, then they are implicitly defined to be: public, static, and final 47

48 Note that a class and an interface in the same package cannot share the same name. Interface declaration Interface names and class names in the same package must be distinct. public interface interface-name { // if any data are defined, they must be constants public static final type-name var-name = constant-expr; // one or more implicitly abstract and public methods return-type method-name ( formal-params ); Method Overriding In a class hierarchy, when a method in a subclass has the same name and type signature as a method in its superclass, then the method in the subclass is said to override the method in the superclass. When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the subclass. The version of the method defined by the superclass will be hidden. 48

49 // Method overriding. class A { int i, j; A(int a, int b) { i = a; j = b; // display i and j void show() { System.out.println("i and j: " + i + " " + j); class B extends A { int k; B(int a, int b, int c) { super(a, b); k = c; // display k this overrides show() in A void show() { System.out.println("k: " + k); class Override { public static void main(string args[]) { B subob = new B(1, 2, 3); subob.show(); // this calls show() in B The output produced by this program is shown here: k: 3 void show() { super.show(); // this calls A's show() System.out.println("k: " + k); Here, super.show( ) calls the superclass version of show( ). If you wish to access the superclass version of an overridden method, you can do so by using super. 49

50 Dynamic Method Dispatch Dynamic method dispatch is the mechanism by which a call to an overridden method is resolved at run time, rather than compile time. Dynamic method dispatch is important because this is how Java implements run-time polymorphism. Important principle: a superclass reference variable can refer to a subclass object. 50

51 // Dynamic Method Dispatch class A { void callme() { System.out.println("Inside A's callme method"); class B extends A { // override callme() void callme() { System.out.println("Inside B's callme method"); class C extends A { // override callme() void callme() { System.out.println("Inside C's callme method"); class Dispatch { public static void main(string args[]) { A a = new A(); // object of type A B b = new B(); // object of type B C c = new C(); // object of type C A r; // obtain a reference of type A r = a; // r refers to an A object r.callme(); // calls A's version of callme r = b; // r refers to a B object r.callme(); // calls B's version of callme r = c; // r refers to a C object r.callme(); // calls C's version of callme The output from the program is shown here: Inside A s callme method Inside B s callme method Inside C s callme method 51

52 52

Unit 3 INFORMATION HIDING & REUSABILITY. -Inheritance basics -Using super -Method Overriding -Constructor call -Dynamic method

Unit 3 INFORMATION HIDING & REUSABILITY. -Inheritance basics -Using super -Method Overriding -Constructor call -Dynamic method Unit 3 INFORMATION HIDING & REUSABILITY -Inheritance basics -Using super -Method Overriding -Constructor call -Dynamic method Inheritance Inheritance is one of the cornerstones of objectoriented programming

More information

Certified Core Java Developer VS-1036

Certified Core Java Developer VS-1036 VS-1036 1. LANGUAGE FUNDAMENTALS The Java language's programming paradigm is implementation and improvement of Object Oriented Programming (OOP) concepts. The Java language has its own rules, syntax, structure

More information

PROGRAMMING LANGUAGE 2

PROGRAMMING LANGUAGE 2 31/10/2013 Ebtsam Abd elhakam 1 PROGRAMMING LANGUAGE 2 Java lecture (7) Inheritance 31/10/2013 Ebtsam Abd elhakam 2 Inheritance Inheritance is one of the cornerstones of object-oriented programming. It

More information

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors Outline Overview history and advantage how to: program, compile and execute 8 data types 3 types of errors Control statements Selection and repetition statements Classes and methods methods... 2 Oak A

More information

JAVA. Lab-9 : Inheritance

JAVA. Lab-9 : Inheritance JAVA Prof. Navrati Saxena TA- Rochak Sachan Lab-9 : Inheritance Chapter Outline: 2 Inheritance Basic: Introduction Member Access and Inheritance Using super Creating a Multilevel Hierarchy Method Overriding

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Outline. 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 information

1 Shyam sir JAVA Notes

1 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 information

Chapter 4 Java Language Fundamentals

Chapter 4 Java Language Fundamentals Chapter 4 Java Language Fundamentals Develop code that declares classes, interfaces, and enums, and includes the appropriate use of package and import statements Explain the effect of modifiers Given an

More information

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

Chapter 1 Introduction to Java

Chapter 1 Introduction to Java What is Java? Chapter 1 Introduction to Java Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows,

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

Programming Language (2) Lecture (4) Supervisor Ebtsam AbdelHakam Department of Computer Science Najran University

Programming Language (2) Lecture (4) Supervisor Ebtsam AbdelHakam Department of Computer Science Najran University Programming Language (2) Lecture (4) Supervisor Ebtsam AbdelHakam ebtsamabd@gmail.com Department of Computer Science Najran University Overloading Methods Method overloading is to define two or more methods

More information

Inheritance. Benefits of Java s Inheritance. 1. Reusability of code 2. Code Sharing 3. Consistency in using an interface. Classes

Inheritance. Benefits of Java s Inheritance. 1. Reusability of code 2. Code Sharing 3. Consistency in using an interface. Classes Inheritance Inheritance is the mechanism of deriving new class from old one, old class is knows as superclass and new class is known as subclass. The subclass inherits all of its instances variables and

More information

Unit 4 - Inheritance, Packages & Interfaces

Unit 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 information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu 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 information

NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT.

NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT. NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT. Object and Classes Data Abstraction and Encapsulation Inheritance Polymorphism Dynamic Binding Message Communication Objects are the basic runtime entities in

More information

Java Professional Certificate Day 1- Bridge Session

Java 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 information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods. Inheritance Inheritance is the act of deriving a new class from an existing one. Inheritance allows us to extend the functionality of the object. The new class automatically contains some or all methods

More information

Introduction to Java

Introduction to Java Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn

More information

Introduction to Programming Using Java (98-388)

Introduction 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 information

Classes. Classes. Classes. Class Circle with methods. Class Circle with fields. Classes and Objects in Java. Introduce to classes and objects in Java.

Classes. Classes. Classes. Class Circle with methods. Class Circle with fields. Classes and Objects in Java. Introduce to classes and objects in Java. Classes Introduce to classes and objects in Java. Classes and Objects in Java Understand how some of the OO concepts learnt so far are supported in Java. Understand important features in Java classes.

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Keyword this. Can be used by any object to refer to itself in any class method Typically used to

Keyword this. Can be used by any object to refer to itself in any class method Typically used to Keyword this Can be used by any object to refer to itself in any class method Typically used to Avoid variable name collisions Pass the receiver as an argument Chain constructors Keyword this Keyword this

More information

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Atelier 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 information

The Java Programming Language

The 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 information

Chapter 6 Introduction to Defining Classes

Chapter 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 information

Hierarchical abstractions & Concept of Inheritance:

Hierarchical abstractions & Concept of Inheritance: UNIT-II Inheritance Inheritance hierarchies- super and subclasses- member access rules- super keyword- preventing inheritance: final classes and methods- the object class and its methods Polymorphism dynamic

More information

20 Most Important Java Programming Interview Questions. Powered by

20 Most Important Java Programming Interview Questions. Powered by 20 Most Important Java Programming Interview Questions Powered by 1. What's the difference between an interface and an abstract class? An abstract class is a class that is only partially implemented by

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

CS260 Intro to Java & Android 02.Java Technology

CS260 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 information

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

CS321 Languages and Compiler Design I. Winter 2012 Lecture 2

CS321 Languages and Compiler Design I. Winter 2012 Lecture 2 CS321 Languages and Compiler Design I Winter 2012 Lecture 2 1 A (RE-)INTRODUCTION TO JAVA FOR C++/C PROGRAMMERS Why Java? Developed by Sun Microsystems (now Oracle) beginning in 1995. Conceived as a better,

More information

STRUCTURING OF PROGRAM

STRUCTURING 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 information

Computer Science II (20073) Week 1: Review and Inheritance

Computer Science II (20073) Week 1: Review and Inheritance Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system

More information

Sri Vidya College of Engineering & Technology

Sri 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 information

Java Basic Datatypees

Java Basic Datatypees Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,

More information

Inherit a class, you simply incorporate the definition of one class into another by using the extends keyword.

Inherit a class, you simply incorporate the definition of one class into another by using the extends keyword. Unit-2 Inheritance: Inherit a class, you simply incorporate the definition of one class into another by using the extends keyword. The general form of a class declaration that inherits a super class is

More information

COP 3330 Final Exam Review

COP 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 information

B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA

B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE

More information

Special Topics: Programming Languages

Special Topics: Programming Languages Lecture #23 0 V22.0490.001 Special Topics: Programming Languages B. Mishra New York University. Lecture # 23 Lecture #23 1 Slide 1 Java: History Spring 1990 April 1991: Naughton, Gosling and Sheridan (

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)

Java. 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 information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

Lecture 1: Overview of Java

Lecture 1: Overview of Java Lecture 1: Overview of Java What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed for easy Web/Internet applications Widespread

More information

Class, Variable, Constructor, Object, Method Questions

Class, Variable, Constructor, Object, Method Questions Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx

More information

Administrivia. Java Review. Objects and Variables. Demo. Example. Example: Assignments

Administrivia. Java Review. Objects and Variables. Demo. Example. Example: Assignments CMSC433, Spring 2004 Programming Language Technology and Paradigms Java Review Jeff Foster Feburary 3, 2004 Administrivia Reading: Liskov, ch 4, optional Eckel, ch 8, 9 Project 1 posted Part 2 was revised

More information

Seminar report Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE

Seminar report Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE A Seminar report On Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE SUBMITTED TO: www.studymafia.org SUBMITTED BY: www.studymafia.org 1 Acknowledgement I would like

More information

S.E. Sem. III [CMPN] Object Oriented Programming Methodology

S.E. Sem. III [CMPN] Object Oriented Programming Methodology S.E. Sem. III [CMPN] Object Oriented Programming Methodology Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 80 Q.1(a) Write a program to calculate GCD of two numbers in java. [5] (A) import java.util.*;

More information

Java Fundamentals (II)

Java 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 information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical 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 information

Java: introduction to object-oriented features

Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Selected Questions from by Nageshwara Rao

Selected Questions from  by Nageshwara Rao Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)

More information

Selected Java Topics

Selected Java Topics Selected Java Topics Introduction Basic Types, Objects and Pointers Modifiers Abstract Classes and Interfaces Exceptions and Runtime Exceptions Static Variables and Static Methods Type Safe Constants Swings

More information

OBJECT ORİENTATİON ENCAPSULATİON

OBJECT 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 information

Programming Language Concepts: Lecture 2

Programming Language Concepts: Lecture 2 Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 2, 19 January 2009 Classes and

More information

Answer1. Features of Java

Answer1. Features of Java Govt Engineering College Ajmer, Rajasthan Mid Term I (2017-18) Subject: PJ Class: 6 th Sem(IT) M.M:10 Time: 1 hr Q1) Explain the features of java and how java is different from C++. [2] Q2) Explain operators

More information

Getting Started With Java

Getting Started With Java Getting Started With Java Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Java - Overview

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

Java Primer. CITS2200 Data Structures and Algorithms. Topic 2

Java Primer. CITS2200 Data Structures and Algorithms. Topic 2 CITS2200 Data Structures and Algorithms Topic 2 Java Primer Review of Java basics Primitive vs Reference Types Classes and Objects Class Hierarchies Interfaces Exceptions Reading: Lambert and Osborne,

More information

S.No Question Blooms Level Course Outcome UNIT I. Programming Language Syntax and semantics

S.No Question Blooms Level Course Outcome UNIT I. Programming Language Syntax and semantics S.No Question Blooms Level Course Outcome UNIT I. Programming Language Syntax and semantics 1 What do you mean by axiomatic Knowledge C254.1 semantics? Give the weakest precondition for a sequence of statements.

More information

15CS45 : OBJECT ORIENTED CONCEPTS

15CS45 : OBJECT ORIENTED CONCEPTS 15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?

More information

1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these. Answer: B

1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these. Answer: B 1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these 2. How many primitive data types are there in Java? A. 5 B. 6 C. 7 D. 8 3. In Java byte, short, int and long

More information

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Java platform. Applets and applications. Java programming language: facilities and foundation. Memory management

More information

Instance Members and Static Members

Instance Members and Static Members Instance Members and Static Members You may notice that all the members are declared w/o static. These members belong to some specific object. They are called instance members. This implies that these

More information

Comments are almost like C++

Comments are almost like C++ UMBC CMSC 331 Java Comments are almost like C++ The javadoc program generates HTML API documentation from the javadoc style comments in your code. /* This kind of comment can span multiple lines */ //

More information

Programming Language Concepts: Lecture 2

Programming Language Concepts: Lecture 2 Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2011 PLC 2011, Lecture 2, 6 January 2011 Classes and

More information

Java Overview An introduction to the Java Programming Language

Java Overview An introduction to the Java Programming Language Java Overview An introduction to the Java Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhan Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/

More information

INHERITANCE. Spring 2019

INHERITANCE. Spring 2019 INHERITANCE Spring 2019 INHERITANCE BASICS Inheritance is a technique that allows one class to be derived from another A derived class inherits all of the data and methods from the original class Suppose

More information

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

More information

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs. Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar

More information

Java Object Oriented Design. CSC207 Fall 2014

Java 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 information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

OVERRIDING. 7/11/2015 Budditha Hettige 82

OVERRIDING. 7/11/2015 Budditha Hettige 82 OVERRIDING 7/11/2015 (budditha@yahoo.com) 82 What is Overriding Is a language feature Allows a subclass or child class to provide a specific implementation of a method that is already provided by one of

More information

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018 Java + OOP CSC207 Winter 2018 1 Why OOP? Modularity: code can be written and maintained separately, and easily passed around the system Information-hiding: internal representation hidden from the outside

More information

Brief Summary of Java

Brief Summary of Java Brief Summary of Java Java programs are compiled into an intermediate format, known as bytecode, and then run through an interpreter that executes in a Java Virtual Machine (JVM). The basic syntax of Java

More information

Chapter 10 Classes Continued. Fundamentals of Java

Chapter 10 Classes Continued. Fundamentals of Java Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an

More information

QUESTIONS FOR AVERAGE BLOOMERS

QUESTIONS FOR AVERAGE BLOOMERS MANTHLY TEST JULY 2017 QUESTIONS FOR AVERAGE BLOOMERS 1. How many types of polymorphism? Ans- 1.Static Polymorphism (compile time polymorphism/ Method overloading) 2.Dynamic Polymorphism (run time polymorphism/

More information

2. The object-oriented paradigm!

2. The object-oriented paradigm! 2. The object-oriented paradigm! Plan for this section:! n Look at things we have to be able to do with a programming language! n Look at Java and how it is done there" Note: I will make a lot of use of

More information

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing Java Programming MSc Induction Tutorials 2011 Stefan Stafrace PhD Student Department of Computing s.stafrace@surrey.ac.uk 1 Tutorial Objectives This is an example based tutorial for students who want to

More information

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5

More information

Declarations and Access Control SCJP tips

Declarations and Access Control  SCJP tips Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for

More information

From C++ to Java. Duke CPS

From C++ to Java. Duke CPS From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed on JVM byte-code is highly-portable, write

More information

CS11 Java. Fall Lecture 1

CS11 Java. Fall Lecture 1 CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon

More information

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995 Java Introduc)on History of Java Java was originally developed by Sun Microsystems star:ng in 1991 James Gosling Patrick Naughton Chris Warth Ed Frank Mike Sheridan This language was ini:ally called Oak

More information

Example: Count of Points

Example: Count of Points Example: Count of Points 1 class Point { 2... 3 private static int numofpoints = 0; 4 5 Point() { 6 numofpoints++; 7 } 8 9 Point(int x, int y) { 10 this(); // calling the constructor with no input argument;

More information

Programming. Syntax and Semantics

Programming. Syntax and Semantics Programming For the next ten weeks you will learn basic programming principles There is much more to programming than knowing a programming language When programming you need to use a tool, in this case

More information

OOPs 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. 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 information

Getting started with Java

Getting started with Java Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly

More information

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

Outline. 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 information

Developed in the beginning of the 1990 s by James Gosling from Sun Microsystems. Formally announced in a major conference in 1995.

Developed in the beginning of the 1990 s by James Gosling from Sun Microsystems. Formally announced in a major conference in 1995. JAVA Developed in the beginning of the 1990 s by James Gosling from Sun Microsystems. Formally announced in a major conference in 1995. Java programs are translated (compiled) into Byte Code format. The

More information

Computer Science II (20082) Week 1: Review and Inheritance

Computer Science II (20082) Week 1: Review and Inheritance Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax

More information

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway Lecture Notes CT 229 Programming II Lecture notes, Sample Programs, Lab Assignments and Tutorials will be available for download at: http://www.nuigalway.ie/staff/ted_scully/ct229/ Lecturer: Dr Ted Scully

More information

CS-202 Introduction to Object Oriented Programming

CS-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 information

CH. 2 OBJECT-ORIENTED PROGRAMMING

CH. 2 OBJECT-ORIENTED PROGRAMMING CH. 2 OBJECT-ORIENTED PROGRAMMING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) OBJECT-ORIENTED

More information

Programming overview

Programming 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 information

A Short Summary of Javali

A Short Summary of Javali A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

More information

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries 1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads

More information

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features The Java programming environment Cleaned up version of C++: no header files, macros, pointers and references, unions, structures, operator overloading, virtual base classes, templates, etc. Object-orientation:

More information