NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT.

Size: px
Start display at page:

Download "NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT."

Transcription

1 NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT.

2 Object and Classes Data Abstraction and Encapsulation Inheritance Polymorphism Dynamic Binding Message Communication

3 Objects are the basic runtime entities in an object oriented system. They may represent a person, a place, a bank account, a table of data or any item that the program may handle. Class is a collection of objects of similar type. A class may be thought of as a data type and an object as a variable of that data type. Once a class has been defined, we can create any no. of objects belonging to that class.

4

5 The wrapping up of data and methods into a single unit (called class) is known as encapsulation. Insulation of data from direct access by the program is called data hiding. Abstractionrefers to the act of representing essential features without including the background details or explanations.

6

7 It is the process by which objects of one class acquires the properties of objects of another class. In OOP, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it.

8 It means the ability to take more than one form. It plays an important role in allowing objects having different internal structure to share the same external interface. It is extensively used in implementing inheritance.

9 Bindingrefers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with the given procedure call is not known until the time of the call at run time.

10 An OOP consists of a set of objects that communicate with each other. The process of programming in an object oriented language, involves the following basic steps : Creating classes that define objects and their behavior Creating objects from class definitions. Establishing communication among objects. Employee.salary(name);

11 Write a note on OOP features with appropriate e.g.

12 Why is java so popular? Platform Independent Provides applet and servletfor use on the web Object oriented programming language. Easy

13 Here, a platform refers to a combination of computer H/W and the operating system on which the code is being executed. Platform independent means we need not to compile the code for each platform. Compilation and execution for C.

14 Compilation and execution for Java.

15 Most commonly used in web based applications. Interaction between the web browser and the web server for getting HTML content. Interaction between the web browser and the web server for getting an Applet.

16 Interaction between web browser and web server for accessing a servlet.

17 All the concepts of OOP

18 Similar to C language. No pointer concept. No bother about de-allocation. De-allocating is taken care by the garbage collector within the JVM. Easy in terms of programming for N/W applications and multi threaded applications.

19 In the mid 1980s, C was one of the most popular language. By the late 1980s,object oriented concepts were well established. Originally, development of Java was started under Project Green, by a group of Sun engineers led by James Gosling called the new language Oak, after the tree outside his window. Later it was found that Oak was already trademarked by Oak Technologies.

20 It was then renamed as Java. At that time java was popular as a language for consumer electronics. However, java really took off as a language for development on the Web, after Sun Microsystems showcased the use of applets in a browser at Sunworld 95 on May 23,1995 (this date is also considered as a birth date of Java). The first version of java was later released in 1996.

21 1JDK Alpha and Beta (1995) 2JDK 1.0 (January 23, 1996) 3JDK 1.1 (February 19, 1997) 4J2SE 1.2 (December 8, 1998) 5J2SE 1.3 (May 8, 2000) 6J2SE 1.4 (February 6, 2002) 7 J2SE 5.0 (September 30, 2004) 8Java SE 6 (December 11, 2006) 9Java SE 7 (July 28, 2011)

22 Installing JDK ( ) Sample Application Compiling Java Files Execution of a Java Application Using Command Line Arguments

23 Note : 1. The name of the public class must match the java file name. the java file may contain a non public class whose name may be different from the file name. 2. A Java file may contain any no. of class definition.

24 2 Categories Primitive Data Types byte short int long float double char boolean Reference Data Types Arrays Classes Interfaces Enums Annotations

25 byte: byte data type is a 8-bit signed two's complement integer. Minimum value is -128 (-2^7) Maximum value is 127 (inclusive)(2^7-1) Default value is 0 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 = -50

26 short: short data type is a 16-bit signed two's complement integer. Minimum value is -32,768 (-2^15) Maximum value is 32,767(inclusive) (2^15-1) Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int Default value is 0. Example : short s= 10000, short r =

27 int: intdata type is a 32-bit signed two's complement integer. Minimum value is - 2,147,483,648.(-2^31) Maximum value is 2,147,483,647(inclusive).(2^31-1) Intis generally used as the default data type for integral values unless there is a concern about memory. The default value is 0. Example : inta = , intb =

28 long: long data type is a 64-bit signed two's complement integer. Minimum value is - 9,223,372,036,854,775,808.(-2^63) Maximum value is 9,223,372,036,854,775,807 (inclusive). (2^63-1) This type is used when a wider range than intis needed. Default value is 0L. Example : long a = L, intb = L

29 float: float data type is a single-precision 32-bit IEEE 754 floating point. float is mainly used to save memory in large arrays of floating point numbers. Default value is 0.0f. Example : float f1 = 234.5f

30 double: double data type is a double-precision 64-bit IEEE 754 floating point. This data type is generally used as the default data type for decimal values. generally the default choice. Default value is 0.0d. Example : double d1 = 123.4

31 boolean: booleandata type represents one bit of information. There are only two possible values : true and false. This data type is used for simple flags that track true/false conditions. Default value is false. Example : booleanone = true

32 char: char data type is a single 16-bit Unicode character. Minimum value is '\u0000' (or 0). Maximum value is '\uffff' (or 65,535 inclusive). Char data type is used to store any character. Example. char lettera ='A'

33 Arrays Classes Interfaces Enums Annotations

34 Data Type Default Value (for fields) byte 0 short 0 int 0 long 0L float 0.0f double 0.0d char String (or any object) boolean '\u0000' null false

35 Escape Sequence Description \t Insert a tab in the text at this point. \b Insert a backspace in the text at this point. \n Insert a newline in the text at this point. \r Insert a carriage return in the text at this point. \f Insert a formfeed in the text at this point. \' \" Insert a single quote character in the text at this point. Insert a double quote character in the text at this point. \\ Insert a backslash character in the text at this point.

36 In Java, the execution starts from main()method. But for compilation, main() is not required. Java's main() method syntax is quiet different from C/C++. Following is the main() method signature public static void main(string args[]) Every word in the above statement has got a meaning to the JVM.

37 1. public:it is a keyword and denotes that any other class (JVM) can call the main() method without any restrictions. 2. static:it is a keyword and denotes that any other class (JVM) can call the main() method without the help of an object. The Java program under execution takes some context area (execution area) in the RAM. JVM is in another context area. To call the main(), the JVM requires an object. When the JVM has not entered into the program, how it can create an object or get an object. To overcome this, allow the JVM to access the main() without object just by declaring static. Once the JVM enters, it can create hundreds of objects later.

38 3. void:it is a keyword and denotes that the main() method does not return a value. 4. main():it is the name of the method. 5. String args[]:the parameter is astring arrayby name args. The string array is used to access command-line arguments.

39 Documentation Section Suggested Package Statement Import Statement Interface Statement Optional Class Definitions Main Method Class { Main Method Definition } Essential

40 The Java language supports three kinds of comments: /*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 JDKjavadoctool uses doc comments when preparing automatically generated documentation. //text The compiler ignores everything from//to the end of the line.

41 Java does not include the c unique statement keywords like goto, sizeof and typedef. Java does not contain data types struct, union and enum. Java does not define the type modifier keyword auto, extern, register, signed and unsigned. Java does not support an explicit pointer type. Java does not have preprocessor and there fore we cannot use #define, #include and #ifdef statements.

42 Java does not support any mechanism for defining variable arguments to functions. Java requires that functions with no arguments must be declared with empty parenthesis and not with the void keyword as done in c. Java adds new operators such as instanceofand >>>. Java adds labeled break and continue statements. Java adds many features required for objectoriented programming.

43 Java does not support operator overloading. Java does not have template classes as in c++. Java does not support multiple inheritance of class and a new feature called interface accomplishes it. Java does not support global variables. Every variable and method is declared within a class and forms part of that class. Java does not use pointers. Java has replaced the destructor function with finalize () function. There is no header file in java.

44 double float long int short char byte

45 We have a relationship of super type and sub type between data types. Thus, the sub type would always be usable wherever the super type is usable. For e.g, in case of primitive data types, intis sub type of long, as intcan always be used wherever long is used. For the reference data types, the super type sub type relationships involve inheritance. The java. lang. Object class is the super type for all the reference data types.

46 There are a couple of special interfaces java.lang.cloneableand java.io.serializable, which are super types for all the array types. The super types for any class, are The direct super class of the class All the super types of this super class The interfaces directly implemented by the class The super types for any interface are The java.lang.object class All the interfaces directly extended by the interface All the super types of the interfaces directly extended by the interface.

47 The super types for an array of any primitive type are The java.lang.object class The java.lang.cloneable interface The java.io.serialiazable interface The super types for an array of any reference type referencetype The arrays of all the super types of the reference type The java.lang.object class The java.lang.cloneableinterface and java.io.serialiazable interface

48 Arithmetic Unary + and String concatenation Relational Logical Bitwise Increment decrement Conditional Assignment, cast and instanceof Other operators ( new, [] and.)

49 If a = 60; and b = 13; Now in binary format they will be as follows: a = b =

50 Op era tor & Description Binary AND Operator copies a bit to the result if it exists in both operands. Example (A & B) will give 12 which is Binary OR Operator copies a bit if it exists in eather operand. (A B) will give 61 which is ^ Binary XOR Operator copies the bit if it is set in one operand but not both. (A ^ B) will give 49 which is ~ Binary Ones Complement Operator is unary and has the efect of (~A ) will give -60 'flipping' bits. which is << Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. A << 2 will give 240 which is >> >>> Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. Shift right zero fill operator. The left operands value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros. A >> 2 will give 15 which is 1111 A >>>2 will give 15 which is

51 variable x = (expression)? value if true : value if false Following is the example: public class Test { public static void main(string args[]) { inta=10, b; b = (a == 1)? 20: 30; System.out.println( "Value of b is : " + b ); b = (a == 10)? 20: 30; System.out.println( "Value of b is : " + b ); } }

52 () is casting operator It is used to convert the type of any expression to one of its sub type. Down casting (<sub type-name>) <expression> Up casting (<super type-name>) <expression> Downcastingin primitive types can result in loss of original value, whereas in case of upcasting there can be loss of precision. Downcastingfor the reference types can result in an error at the runtime.

53 E.g. Not result in any loss of value for the code int s = 75; byte b = (byte) s; Loss of original value int s= 375; byte b = (byte) s; No errors Run time error Vehicle v = new Car(); Car c = (Car) v; Vehicle v = new Scooter(); Car c = (Car) v;

54 This operator is used only for object reference variables. The operator checks whether the object is of a particular type(class type or interface type). instanceof operator is written as: ( Object reference variable ) instanceof (class/interface type) E.g. : String name = 'James'; booleanresult = name instanceofstring; // This will return true since name is type of String

55 The new operator is always used to create a new instance of some class or for allocating an array of any data type. This can result in an error at the runtime if there is not enough memory to do the allocation for the instance being created. The [] operator is used to access the elements of array. This operator requires an int expression. There can be an error at the runtime if the value of an expression used to access the element is not in the range from 0 to the length of array 1.

56 The. Operator is used to access any member of an instance or invoking methods on an instance. This can also result in an error at the runtime in case we try to access any member for the null value.

57 Condition statements if if else switch - case Loop statements for while do -while break, continue and return

58 Narrowing and widening conversion Boxing - unboxing

59 A widening conversion is the conversion of sub type to one of its super types. For numeric types, the following are the widening conversions : byte to short, int, long, float or double short to int, long, float, or double char to int, long, float or double intto long, float or double long to float or double float to double E. g. inti = ; float f = I;

60 The narrowing conversion is the conversion of a super type to one of its sub type. For numeric types, the following are the narrowing conversion : double to byte, short, char, int, long or float float to byte, short, char, int, or long long to byte, short, char, or int intto byte, short or char short to byte E.g. int a=128; byte b; b=(byte)a; Here variable b will contain 1 as the calculation of 128%127.

61 A mixed conversion is the conversion that involves first a widening conversion followed by a narrowing conversion. For numeric types, the following are the cases for mixed conversions : char to byte or short short to char byte to char E.g. for char to byte first we need widening conversion (from char to int) and then narrowing conversion (int to byte)

62 Access-specifier class Class_Name { //members of class }

63 Instance variables Methods Constructors Garbage Collector and The finalize method Static variable and static methods Initializer block Class initializer block

64 (Refer class book)

65 (Refer class book)

66 A java constructorhas the same name as the name of the class to which it belongs. Constructor s syntax does not include a return type, since constructors never return a value. Constructors may include parameters of various types. When the constructor is invoked using the new operator, the types must match those that are specified in the constructor definition. Java provides a default constructor which takes no arguments and performs no special actions or initializations, when no explicit constructors are provided. E.g. (Refer class book)

67 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 ofjava memory spaceand both heap and method area is shared between different thread. 2) Garbage collection is a mechanism provided by Java Virtual Machine to reclaim heap spacefrom objects which are eligible for Garbage collection. 3) Garbage collectionrelieves java programmer from memory managementwhich is essential part of C++ programming and gives more time to focus on business logic.

68 4) Garbage Collection in Javais carried by a daemon thread called Garbage Collector. 5) Before removing an object from memory Garbage collection thread invokes finalize () methodof that object and gives an opportunity to perform any sort of cleanup required. 6) You as Java programmer can not force Garbage collection in Java; it will only triggerif JVM thinks it needs a garbage collection based on Java heap size.

69 7) There are methods like System.gc ()and Runtime.gc() which is used to send request of Garbage collection to JVMbut it snot guaranteed that garbage collection will happen. 8) If there is no memory space for creating new object in Heap Java Virtual Machine throws OutOfMemoryError or java.lan g.outofmemoryerror heap space

70 protected void finalize() { //content }

71 static variable It is a variable which belongs to the class and not to object(instance) Static variables are initialized only once, at the start of the execution. These variables will be initialized first, before the initialization of any instance variables A single copyto be shared by all instances of the class A static variable can be accessed directlyby the class nameand doesn t need any object Syntax : <class-name>.<variable-name>

72 static method It is a method which belongs to the class and not to the object(instance) A static method can access only static data. It can not access non-static data (instance variables) A static method can call onlyother static methodsand can not call a non-static method from it. A static method can be accessed directlyby the class nameand doesn t need any object Syntax : <class-name>.<method-name> A static method cannot refer to this or super keywords in anyway

73 Class Initializer block In a class definition, we can have a member block with no name. Such a block is known as initializer block. An initializerblock is never invoked by any application directly since it does not have any name. However, it is always invoked on an instance as soon as it is allocated. It is invoked just before the constructor is invoked on the instance.

74 Syntax : class classname { { //initializer block }.. }

75 Class initializer block Just like we have the constructor for initializing the instance variables, we use the class initializerblock to initialize class variables. A class initializerblock is created just like the initializer block, but it is declared to be static. We also call this block as the static block. This block is automatically executed whenever the class is loaded. The class would be loaded by the JVM only if the class is used in an application

76 Syntax : class classname { static { //class initializer block }.. }

77 Explain java features in detail. Java data types with super type and sub type relationship Write a short note on type conversion. Static variable and static methods Constructor and constructor overloading Garbage collection Initializer block and class initializer block

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

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

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

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

Operators and Expressions

Operators and Expressions Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions

More information

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

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

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

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

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

Tools : The Java Compiler. The Java Interpreter. The Java Debugger Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

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

CS201 - Introduction to Programming Glossary By

CS201 - 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 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

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

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

2 rd class Department of Programming. OOP with Java Programming

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

Short Notes of CS201

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

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

Introduction to Programming (Java) 2/12

Introduction to Programming (Java) 2/12 Introduction to Programming (Java) 2/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS Java language Part 1. Java fundamentals Yevhen Berkunskyi, NUoS eugeny.berkunsky@gmail.com http://www.berkut.mk.ua What Java is? Programming language Platform: Hardware Software OS: Windows, Linux, Solaris,

More information

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following g roups:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following g roups: JAVA BASIC OPERATORS http://www.tuto rialspo int.co m/java/java_basic_o perato rs.htm Copyrig ht tutorialspoint.com Java provides a rich set of operators to manipulate variables. We can divide all the

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

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

The Java language has a wide variety of modifiers, including the following:

The Java language has a wide variety of modifiers, including the following: PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

B.V. Patel Institute of BMC & IT, UTU 2014

B.V. Patel Institute of BMC & IT, UTU 2014 BCA 3 rd Semester 030010301 - Java Programming Unit-1(Java Platform and Programming Elements) Q-1 Answer the following question in short. [1 Mark each] 1. Who is known as creator of JAVA? 2. Why do we

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

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

.Net Technologies. Components of.net Framework

.Net Technologies. Components of.net Framework .Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.

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

Values and Variables 1 / 30

Values and Variables 1 / 30 Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides

More information

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

The Sun s Java Certification and its Possible Role in the Joint Teaching Material The Sun s Java Certification and its Possible Role in the Joint Teaching Material Nataša Ibrajter Faculty of Science Department of Mathematics and Informatics Novi Sad 1 Contents Kinds of Sun Certified

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

Java: framework overview and in-the-small features

Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Language Fundamentals Summary

Language Fundamentals Summary Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt, Michael Skusa Software Systems Institute Object-oriented Analysis and Design 1999/2000 c.niederee@tu-harburg.de http://www.sts.tu-harburg.de

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

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

Programming in C++ 4. The lexical basis of C++

Programming in C++ 4. The lexical basis of C++ Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++

More information

Question. 1 Features of Java.

Question. 1 Features of Java. QUESTIONS BANK (CP-II) No Question 1 Features of Java. QUESTIONS BANK (CP-II) ( Using java) QUESTIONS BANK (CP-II) or Java Features:- (1) Java Is Small and Simple Java is modeled after C and C++. The object-oriented

More information

Object Oriented Programming. Solved MCQs - Part 2

Object Oriented Programming. Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What

More information

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

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

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

CMPT 125: Lecture 3 Data and Expressions

CMPT 125: Lecture 3 Data and Expressions CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,

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

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail. OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce

More information

SECTION II: LANGUAGE BASICS

SECTION II: LANGUAGE BASICS Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators

More information

Java An Introduction. Outline. Introduction

Java An Introduction. Outline. Introduction Java An Introduction References: Internet Course notes by E.Burris Computing Fundamentals with Java, by Rick Mercer Beginning Java Objects - From Concepts to Codeby Jacquie Barker Object-Oriented Design

More information

Compaq Interview Questions And Answers

Compaq Interview Questions And Answers Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not

More information

Getting started with Java

Getting started with Java Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

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

Programming Language Basics

Programming Language Basics Programming Language Basics Lecture Outline & Notes Overview 1. History & Background 2. Basic Program structure a. How an operating system runs a program i. Machine code ii. OS- specific commands to setup

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

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

Lecture 02 C FUNDAMENTALS

Lecture 02 C FUNDAMENTALS Lecture 02 C FUNDAMENTALS 1 Keywords C Fundamentals auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

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

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

(2½ hours) Total Marks: 75

(2½ hours) Total Marks: 75 (2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Makesuitable assumptions wherever necessary and state the assumptions mad (3) Answers to the same question must be written together.

More information

Learning the Java Language. 2.1 Object-Oriented Programming

Learning the Java Language. 2.1 Object-Oriented Programming Learning the Java Language 2.1 Object-Oriented Programming What is an Object? Real world is composed by different kind of objects: buildings, men, women, dogs, cars, etc. Each object has its own states

More information

Java Programming. Atul Prakash

Java Programming. Atul Prakash Java Programming Atul Prakash Java Language Fundamentals The language syntax is similar to C/ C++ If you know C/C++, you will have no trouble understanding Java s syntax If you don't, it will be easier

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

Sample Copy. Not for Distribution.

Sample Copy. Not for Distribution. A Practical Approach to Learn JAVA i EDUCREATION PUBLISHING RZ 94, Sector - 6, Dwarka, New Delhi - 110075 Shubham Vihar, Mangla, Bilaspur, Chhattisgarh - 495001 Website: www.educreation.in Copyright, 2018,

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

WA1278 Introduction to Java Using Eclipse

WA1278 Introduction to Java Using Eclipse Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc WA1278 Introduction to Java Using Eclipse This course introduces the Java

More information

Character Stream : It provides a convenient means for handling input and output of characters.

Character Stream : It provides a convenient means for handling input and output of characters. Be Perfect, Do Perfect, Live Perfect 1 1. What is the meaning of public static void main(string args[])? public keyword is an access modifier which represents visibility, it means it is visible to all.

More information

Program Fundamentals

Program Fundamentals Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java

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

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure C Overview Basic C Program Structure C OVERVIEW BASIC C PROGRAM STRUCTURE Goals The function main( )is found in every C program and is where every C program begins speed execution portability C uses braces

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

Zheng-Liang Lu Java Programming 45 / 79

Zheng-Liang Lu Java Programming 45 / 79 1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius

More information

Programming in C and C++

Programming in C and C++ Programming in C and C++ 1. Types Variables Expressions & Statements Dr. Anil Madhavapeddy University of Cambridge (based on previous years thanks to Alan Mycroft, Alastair Beresford and Andrew Moore)

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING Unit I : OVERVIEW PART A (2 Marks) 1. Give some characteristics of procedure-oriented

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

An overview of Java, Data types and variables

An overview of Java, Data types and variables An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public

More information

Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003

Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003 Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void

More information

A Java program contains at least one class definition.

A Java program contains at least one class definition. Java Programs Identifiers Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 A Java program contains at least one class definition. public class Hello { public

More information

JAVA OPERATORS GENERAL

JAVA OPERATORS GENERAL JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Objects and Iterators

Objects and Iterators Objects and Iterators Can We Have Data Structures With Generic Types? What s in a Bag? All our implementations of collections so far allowed for one data type for the entire collection To accommodate a

More information

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed C Overview C OVERVIEW Goals speed portability allow access to features of the architecture speed C fast executables allows high-level structure without losing access to machine features many popular languages

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

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

Structure of this course. C and C++ Past Exam Questions. Text books

Structure of this course. C and C++ Past Exam Questions. Text books Structure of this course C and C++ 1. Types Variables Expressions & Statements Alastair R. Beresford University of Cambridge Lent Term 2008 Programming in C: types, variables, expressions & statements

More information

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name

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

Object-Oriented Programming (OOP) Fundamental Principles of OOP

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

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

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 information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

Lecture Set 4: More About Methods and More About Operators

Lecture Set 4: More About Methods and More About Operators Lecture Set 4: More About Methods and More About Operators Methods Definitions Invocations More arithmetic operators Operator Side effects Operator Precedence Short-circuiting main method public static

More information

Computers Programming Course 6. Iulian Năstac

Computers Programming Course 6. Iulian Năstac Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap

More information

A flow chart is a graphical or symbolic representation of a process.

A flow chart is a graphical or symbolic representation of a process. Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of

More information

Core Java Syllabus. Overview

Core Java Syllabus. Overview Core Java Syllabus Overview Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

Preview from Notesale.co.uk Page 9 of 108

Preview from Notesale.co.uk Page 9 of 108 The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names. abstract assert boolean break byte case catch char class

More information