S.E (Computer ) (Second Semester) EXAMINATION, Time : Two Hours Maximum Marks : 50

Size: px
Start display at page:

Download "S.E (Computer ) (Second Semester) EXAMINATION, Time : Two Hours Maximum Marks : 50"

Transcription

1 S.E (Computer ) (Second Semester) EXAMINATION, 2017 PRINCIPLES OF PROGRAMMING LANGUAGE (2015 PATTERN) Time : Two Hours Maximum Marks : 50 N.B. :- (i) All questions are compulsory (ii)neat diagrams must be drawn wherever necessary. (iii) Figures to the right indicate full marks. (iv) Assume suitable data, if necessary. Q.No Question. Blooms Taxonomy CO Marking Scheme 1 (a) Draw and Explain the SDLC ( 6 ) Knowledge 5 Draw 2 Explain -4 (b) Distinguish named and structure type compatibility(3) Understand 2 Each correct points 1 (c) List & describe programming language qualities(3) Knowledge 1 List -1 Describe (a) Describe the String class & its methods in Java. (5) Knowledge 5 List-1 Explain 3 (b) (c) Differentiate between separate and independent compilation (4) Give and clarify the basic structure of PASCAL program(3) Understand 2 Understand 4 Each correct comparison 1 mark Structure -1 Clarification 2 3 (a) Write Java program for hierarchical inheritance (6) Create 5 Each Class- 1 Main Class- 3 (b) Explain dynamic method dispatch procedure with Explain -2 Example 2 Knowledge 5 suitable example. (4) (c) How to create and access package in Java? (3) Knowledge 5 Creation 2 Access- 1 4 (a) Write a program to input a string and raises a user defined exception if the string contains less than 8 characters. (8) (b) Describe the following attributes of <APPLET > tag i. codebase ii. Code iii width iv. Alt v. Param (5) Create 5 Knowledge 6 Input 2 Defining User defined Exception Class- 2 and Main Logic 4 Each Attribute 1 S.E (Computer ) (Second Semester) EXAMINATION, 2017 PRINCIPLES OF PROGRAMMING LANGUAGE (2015 PATTERN) Time : Two Hours Maximum Marks : 50 N.B. :- (i) All questions are compulsory (ii)neat diagrams must be drawn wherever necessary. (iii) Figures to the right indicate full marks. (iv) Assume suitable data, if necessary. Q.No Question. Blooms Taxonomy CO Marking Scheme 1 (a) Draw and Explain the SDLC ( 6 ) Knowledge 5 Draw 2 Explain -4 (b) Distinguish named and structure type compatibility(3) Understand 2 Each correct points 1 (c) List & describe programming language qualities(3) Knowledge 1 List -1 Describe (a) Describe the String class & its methods in Java. (5) Knowledge 5 List-1 Explain 4 (b) (c) Differentiate between separate and independent compilation (4) Give and clarify the basic structure of PASCAL program(3) Understand 2 Understand 4 Each correct comparison 1 mark Structure -1 Clarification 2 3 (a) Write Java program for hierarchical inheritance (6) Create 5 Each Class- 1 Main Class- 3 (b) Explain dynamic method dispatch procedure with Explain -2 Example 2 Knowledge 5 suitable example. (4) (c) How to create and access package in Java? (3) Knowledge 5 Creation 2 Access- 1 4 (a) Write a program to input a string and raises a user defined exception if the string contains less than 8 characters. (8) (b) Describe the following attributes of <APPLET > tag i. codebase ii. Code iii width iv. Alt v. Param (5) Create 5 Knowledge 6 Input 2 Defining User defined Exception Class- 2 and Main Logic 4 Each Attribute 1

2 Q.1 a) SDLC consists of following activities: 1. Planning: The most important parts of software development, requirement gathering or requirement analysis are usually done by the most skilled and experienced software engineers in the organization. After the requirements are gathered from the client, a scope document is created in which the scope of the project is determined and documented. 2. Implementation: The software engineers start writing the code according to the client's requirements. 3. Testing: This is the process of finding defects or bugs in the created software. 4. Documentation: Every step in the project is documented for future reference and for the improvement of the software in the development process. The design documentation may include writing the application programming interface (API). 5. Deployment and maintenance: The software is deployed after it has been approved for release. 6. Maintaining: Software maintenance is done for future reference. Software improvement and new requirements (change requests) can take longer than the time needed to create the initial development of the software. There are several software development models followed by various organizations: Waterfall Model: This model involves finishing each phase completely before commencing the next one. When each phase is completed successfully, it is reviewed to see if the project is on track and whether it is feasible to continue. V-Shaped Model: This model focuses on the execution of processes in a sequential manner, similar to the waterfall model but with more importance placed on testing. Testing procedures are written even before the commencement of writing code. A system plan is generated before starting the development phase. Incremental Model: This life cycle model involves multiple development cycles. The cycles are divided up into smaller iterations. These iterations can be easily managed and go through a set of phases including requirements, design, implementation and testing. A working version of the software is produced during the first iteration, so working software is created early in the development process.

3 Q.1 b) S.No Name Type Compatibility Structure Type Compatibity Name type compatibility ( name equivalence ) means that two variables have compatible types Type compatibility by structure ( structural equivalence) means that two 1 if variables have compatible types if their 1. They are defined in the same declaration types have identical structures. 2. They are defined in declarations that uses the same type name. 2 Easy to implement but highly restrictive More flexible, but harder to implement Subranges of integer types are not compatible with integer types. 3 4 Example : int x,a; x and a both are name equivalent as both are of type integer With structural type compatibility, you cannot differentiate between types of the same structure (e.g. different units of speed, both float) Example : type s1 is struct type s2 is struct { { int y; int w; int y; int w; ; ; In above s1 and s2 are structure equivalent 5 Pascal is Name Compatible C is Structure equivalent Q.1 c) Programming language qualities are : 1. Reliable (no failure) 2. Maintainable (new requirements be easily added..or modified) 3. Efficient (speedy and less space) 1. Reliability is achieved by. Writability : Higher-level languages are more writable than low-level Readabililty: Provision of adding new operations and data types easily enhances readability Simplicity: Allow algorithms to be expressed easily, Eg. Pascal is simpler than C++ but less powerful Safety : If language provides no features that make it possible to write harmful programs.. like goto then its safe Robustness: Ability to deal with undesired events like arithmetic overflow. 2. Maintainability is achieved by. a. Factoring : The language should allow programming to factor related features into one single unit. b. Locality : The effect of language feature is restricted to small local portion of the entire program otherwise if it extends to most of the program the task of making the changes can be exceedingly complex.\ 3. Efficiency earlier was measured by execution speed and space Now-a-days we can measure it by combined quality of language and its implementation If a language does not allow optimization it may adversely affect efficiency

4 Q.2 a) Java String Class and its methods Ans. String is nothing but a sequence of characters, for e.g. Hello is a string of 5 characters. In java, string is an immutable object which means it is constant and cannot be changed once it has been created. Creating a String : There are two ways to create a String in Java 1. String literal 2. Using new keyword 1. String literal In java, Strings can be created like this: Assigning a String literal to a String instance: String str1 = "Welcome"; String str2 = "Welcome"; 2. Using New Keyword String str1 = new String("Welcome"); String str2 = new String("Welcome"); String Methods 1) char charat(int index): It returns the character at the specified index. Specified index value should be between 0 to length() -1 both inclusive. It throws IndexOutOfBoundsException if index<0 >= length of String. 2) boolean equals(object obj): Compares the string with the specified string and returns true if both matches else false. 3) int compareto(string string): This method compares the two strings based on the Unicode value of each character in the strings. 4) boolean startswith(string prefix): It tests whether the string is having specified prefix, if yes then it returns true else false. 5) int indexof(int ch): Returns the index of first occurrence of the specified character ch in the string. 6) int lastindexof(int ch): It returns the last occurrence of the character ch in the string. 7) String tolowercase(): Equivalent to tolowercase(locale. getdefault()). 8) String touppercase(locale locale): Converts the string to upper case string using the rules defined by specified locale. 9) int length(): It returns the length of a String. Q.2 b) S.No Separate Compilation Independent Compilation 1 The term separate compilation means compile units individually however their compilations are dependent of each other. Program units are compiled separately as well as their compilations are independent of each other. 2 Interface information is used to check the It does not need interface information to correctness of the interface between the parts. check the correctness. 3 It needs information of all program units It does not need any information of other 4 Ada, Modula-2, FORTRAN -90 supports separate compilation. program units. C, FORTRAN-77 supports independent compilation

5 Q.2 c) Every Pascal program must follow a basic structure. Below is the basic structure that every Pascal program must follow. PROGRAM ProgramName (FileList); variables here if necessary CONST (* Constant declarations *) TYPE (* Type declarations *) VAR (* Variable declarations *) (* Subprogram definitions *) FUNCTION FunctionName(variableList): VariableType; (* variables here if necessary *) BEGIN (* Some Code if necessary; *) (* FunctionName := some expression *) (* More Code if necessary; *) END; BEGIN (* Executable statements *) END. The program statement has the form Program ProgramName (FileList); The ProgramName is the name of the program. The FileList that are enclosed in parentheses in the program template are input and output. These are just there for form -- their presence means nothing. More file variables may be added to this list, but this has no meaning to the program. All declarations following the program statement (before any function or procedure declarations) are global to the entire program. A declaration is basically just a statement; For example: const FirstLetter='a'; This "declares" that the constant named FirstLetter is equal to lowercase 'a'. Type and Variable declarations can be a bit more complicated, but all declarations follow the same basic principle. You are outlining for the compiler what some part of the program is, or what it is equal to. The template above is not a legitimate pascal program. If you don't have any constants, types, or variables to declare, you should leave out the corresponding section. So, the above template, minus the unused sections, would give the following (working) program: program PROGRAMNAME; begin end.

6 Obviously, this program doesn't actually DO anything. It just starts up, then exits. But it illustrates the most basic building block you need for a working program. Q.3 a) class HierarchicalInheritance { void Display() { System.out.println("This is a content of parent class"); //A.java class A extends HierarchicalInheritance { void DisplayA() { System.out.println("This is a content of child class 1"); //B.java class B extends HierarchicalInheritance { void DisplayB() { System.out.println("This is a content of child class 2"); //HierarchicalInheritanceMain.java class HierarchicalInheritanceMain { public static void main(string args[]) { System.out.println("Calling for child class A"); A aob = new A(); aob.display(); aob.displaya(); System.out.println("Calling for child class B"); B obb = new B(); obb.display(); obb.displayb(); Q.3 b) Runtime Polymorphism or Dynamic method dispatch Dynamic method dispatch is a mechanism by which a call to an overridden method is resolved at runtime. This is how java implements runtime polymorphism. When an overridden method is called by a reference, java determines which version of that method to execute based on the type of object it refer to. In simple words the type of object which it referred determines which version of overridden method will be called.

7 When Parent class reference variable refers to Child class object, it is known as Upcasting Example class Game { public void type() { System.out.println("Indoor & outdoor"); Class Cricket extends Game { public void type() { System.out.println("outdoor game"); public static void main(string[] args) { Game gm = new Game(); Cricket ck = new Cricket(); gm.type(); ck.type(); gm=ck; //gm refers to Cricket object gm.type(); //calls Cricket's version of type Output : Indoor & outdoor Outdoor game Outdoor game Notice the last output. This is because of gm = ck; Now gm.type() will call Cricket version of type method. Because here gm refers to cricket object. Q.3 c) A java package is a group of similar types of classes, interfaces and sub-packages. Package in java can be categorized in two form, built-in package and user-defined package. There are many built-in packages such as java, lang, awt, javax, swing, net, io, util, sql etc. Advantage of Java Package Java package is used to categorize the classes and interfaces so that they can be easily maintained. Java package provides access protection. Java package removes naming collision. Simple example of java package The package keyword is used to create a package in java.

8 //save as Simple.java package mypack; public class Simple{ public static void main(string args[]){ System.out.println("Welcome to package"); How to compile java package $ javac -d directory javafilename For example $ javac -d. Simple.java The -d switch specifies the destination where to put the generated class file. You can use any directory name like /home (in case of Linux), d:/abc (in case of windows) etc. If you want to keep the package within the same directory, you can use. (dot). How to run java package program You need to use fully qualified name e.g. mypack.simple etc to run the class. To Compile: javac -d. Simple.java To Run: java mypack.simple Output:Welcome to package The -d is a switch that tells the compiler where to put the class file i.e. it represents destination. The. represents the current folder. How to access package from another package? import package.*; The import keyword is used to make the classes and interface of another package accessible to the current package. Example of package that import the packagename.* //save by A.java package pack; public class A{ public void msg(){system.out.println("hello"); //save by B.java package mypack; import pack.*; class B{ public static void main(string args[]){ A obj = new A(); obj.msg(); Output:Hello

9 Q.4 a) import java.util.*; class MyException extends Exception{ MyException(String str2) { str1 = str2; public String tostring(){ return ("Output String = "+str1) ; class CustomException{ public static void main(string args[]){ Scanner s1; try{ System.out.print( Enter a string : ); String str = s1.nextline(); int len = str.length(); if (len<8) throw new MyException( String less than 8 characters ); // I'm throwing user defined custom exception above catch(myexception exp){ System.out.println("Hi this is my catch block") ; System.out.println(exp) ;

10 Q. 4b) APPLET CODE = class file (file or URL) HEIGHT = pixels WIDTH = pixels [ CODEBASE = URL directory ] // [ ] square brackets indicate optional tags [ ALT = alternate text message ] [ ARCHIVE = names of JAR files ] [ ALIGN = alignment ] [ NAME = name for other applets on page ] [ HSPACE = pixel ] [ VSPACE = pixel ] > // notice all these instructions are enclosed withing the first applet tag [ < PARAM NAME = identifier VALUE = value > ] [ < PARAM NAME = identifier VALUE = value > ] [alternate HTML ] </ APPLET > WIDTH & HEIGHT Tags - specify the width and height of the applet in pixels CODE & CODEBASE Tags Applet code that will run in an HTML page is specified with the CODE tag. Example Code="X.class" // quotes can be left out on the class identifier but it is good HTML form to quote all attribute values The CODEBASE tag is used to specify an absolute path, a URL, or a relative path (relative to where the calling HTML file is located). The java class identifer is case sensitive and must end with the.class extension. PARAM Tag PARAM tags appear between the <APPLET> param tags </APPLET> This tag allows data to be passed from an HTML page to an applet on that page. <APPLET CODE = Thermostat.class WIDTH = 200 HEIGHT = 200 > < PARAM NAME = label VALUE = "My Excellent Thermostat" > // note quotes allow inclusion of spaces < PARAM NAME = scale VALUE = celsius > < PARAM NAME = increment VALUE = 2 > </ APPLET > An applet reading these values uses the NAME identifiers as parameters to the getparameter( ) method. (Going in, case is not significant.) The string value returned, (representing the VALUE assignment) however is case sensitive. ALT Tag The ALT tag provides an altenate text for browsers that know the tag but don't support applets.

11 1. < APPLET CODE = Thermostat.class WIDTH = 200 HEIGHT = ALT = " Try another browser!" > 3. < /APPLET >

* Mrs. K.M. Sanghavi

* Mrs. K.M. Sanghavi * Mrs. K.M. Sanghavi *Packages are those class which contains methods without the main method in them. *Packages are mainly used to reuse the classes which are already created/used in other program. *We

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

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

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

Method Overriding in Java

Method Overriding in Java Method Overriding in Java Whenever same method name is existing in both base class and derived class with same types of parameters or same order of parameters is known as method Overriding. Method must

More information

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani The HTML APPLET Tag An applet viewer will execute each APPLET tag that it finds in a separate window, while web browsers

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

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

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

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

String is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents

String is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents String is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents character strings. All string literals in Java programs,

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

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

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

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

5. PACKAGES AND INTERFACES

5. PACKAGES AND INTERFACES 5. PACKAGES AND INTERFACES JAVA PROGRAMMING(2350703) Packages: A is a group of classes and interfaces. Package can be categorized in two form: built-in such as java, lang, awt, javax, swing, net, io, util,

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

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Internal Examination 1 Answer Key DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Branch & Sec : CSE Date : 08.08.2014 Semester : V Sem Max Marks : 50 Marks Sub Code& Title : CS2305 Programming Paradigms

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative

More information

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can

More information

Introduction to Java Unit 1. Using BlueJ to Write Programs

Introduction to Java Unit 1. Using BlueJ to Write Programs Introduction to Java Unit 1. Using BlueJ to Write Programs 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save

More information

AP Computer Science Unit 1. Writing Programs Using BlueJ

AP Computer Science Unit 1. Writing Programs Using BlueJ AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save

More information

Fundamentals of Object Oriented Programming

Fundamentals of Object Oriented Programming INDIAN INSTITUTE OF TECHNOLOGY ROORKEE Fundamentals of Object Oriented Programming CSN- 103 Dr. R. Balasubramanian Associate Professor Department of Computer Science and Engineering Indian Institute of

More 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

.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

COMP 202 Java in one week

COMP 202 Java in one week COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of

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

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

Chapter 7 Applets. Answers

Chapter 7 Applets. Answers Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point

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

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

Object Oriented Programming and Design in Java. Session 2 Instructor: Bert Huang

Object Oriented Programming and Design in Java. Session 2 Instructor: Bert Huang Object Oriented Programming and Design in Java Session 2 Instructor: Bert Huang Announcements TA: Yipeng Huang, yh2315, Mon 4-6 OH on MICE clarification Next Monday's class canceled for Distinguished Lecture:

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

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

AP Computer Science Unit 1. Writing Programs Using BlueJ

AP Computer Science Unit 1. Writing Programs Using BlueJ AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save

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

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application Last Time v We created our first Java application v What are the components of a basic Java application? v What GUI component did we use in the examples? v How do we write to the standard output? v An

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

CS 11 java track: lecture 1

CS 11 java track: lecture 1 CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml

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

Module 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet

Module 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet About Applets Module 5 Applets An applet is a little application. Prior to the World Wide Web, the built-in writing and drawing programs that came with Windows were sometimes called "applets." On the Web,

More information

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name:

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name: CSC 1051 Algorithms and Data Structures I Midterm Examination March 2, 2017 Name: Question Value Score 1 10 2 10 3 20 4 20 5 20 6 20 TOTAL 100 Please answer questions in the spaces provided. If you make

More information

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it. Introduction to JAVA JAVA is a programming language which is used in Android App Development. It is class based and object oriented programming whose syntax is influenced by C++. The primary goals of JAVA

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

SPARK-PL: Introduction

SPARK-PL: Introduction Alexey Solovyev Abstract All basic elements of SPARK-PL are introduced. Table of Contents 1. Introduction to SPARK-PL... 1 2. Alphabet of SPARK-PL... 3 3. Types and variables... 3 4. SPARK-PL basic commands...

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

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

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

JAVA: A Primer. By: Amrita Rajagopal

JAVA: A Primer. By: Amrita Rajagopal JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently

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

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5 Outline Name, Scope and Binding In Text: Chapter 5 Names Variable Binding Type bindings, type conversion Storage bindings and lifetime Scope Lifetime vs. Scope Referencing Environments N. Meng, S. Arthur

More information

Chapter 1: Introduction to Computers, Programs, and Java

Chapter 1: Introduction to Computers, Programs, and Java Chapter 1: Introduction to Computers, Programs, and Java 1. Q: When you compile your program, you receive an error as follows: 2. 3. %javac Welcome.java 4. javac not found 5. 6. What is wrong? 7. A: Two

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

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

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

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

Introduction to Java (All the Basic Stuff)

Introduction to Java (All the Basic Stuff) Introduction to Java (All the Basic Stuff) Learning Objectives Java's edit-compile-run loop Basics of object-oriented programming Classes objects, instantiation, methods Primitive types Math expressions

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

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

Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Scope and Lifetime Type Checking Referencing Environments Named Constants Names Used for variables, subprograms

More information

NOTE: Answer ANY FOUR of the following 6 sections:

NOTE: Answer ANY FOUR of the following 6 sections: A-PDF MERGER DEMO Philadelphia University Lecturer: Dr. Nadia Y. Yousif Coordinator: Dr. Nadia Y. Yousif Internal Examiner: Dr. Raad Fadhel Examination Paper... Programming Languages Paradigms (750321)

More information

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4 Assignments Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4 Lecture 6 Complete for Lab 4, Project 1 Note: Slides 12 19 are summary slides for Chapter 2. They overview much of what we covered but are not complete.

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

A variable is a name for a location in memory A variable must be declared

A variable is a name for a location in memory A variable must be declared Variables A variable is a name for a location in memory A variable must be declared, specifying the variable's name and the type of information that will be held in it data type variable name int total;

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

CS506 Web Design & Development Final Term Solved MCQs with Reference

CS506 Web Design & Development Final Term Solved MCQs with Reference with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar

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

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Copyright 1992-2015 by Pearson Education, Inc. All Rights Reserved. Data structures Collections of related data items. Discussed in depth in Chapters 16 21. Array objects Data

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

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi UNIT II Structuring the Data, Computations and Program B y Kainjan Sanghavi Contents Monomorphic versus polymorphic type systems Case Study- The type structure of C++ and Java Structuring the computation

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

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

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 9: Writing Java Applets. Introduction

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 9: Writing Java Applets. Introduction INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 9: Writing Java Applets Introduction Applets are Java programs that execute within HTML pages. There are three stages to creating a working Java

More information

Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 06 Demonstration II So, in the last lecture, we have learned

More information

4 Programming Fundamentals. Introduction to Programming 1 1

4 Programming Fundamentals. Introduction to Programming 1 1 4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,

More information

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics WIT COMP1000 Java Basics Java Origins Java was developed by James Gosling at Sun Microsystems in the early 1990s It was derived largely from the C++ programming language with several enhancements Java

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

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

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

5/23/2015. Core Java Syllabus. VikRam ShaRma

5/23/2015. Core Java Syllabus. VikRam ShaRma 5/23/2015 Core Java Syllabus VikRam ShaRma Basic Concepts of Core Java 1 Introduction to Java 1.1 Need of java i.e. History 1.2 What is java? 1.3 Java Buzzwords 1.4 JDK JRE JVM JIT - Java Compiler 1.5

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

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different

More information

AP CS Unit 3: Control Structures Notes

AP CS Unit 3: Control Structures Notes AP CS Unit 3: Control Structures Notes The if and if-else Statements. These statements are called control statements because they control whether a particular block of code is executed or not. Some texts

More information

Mr. Monroe s Guide to Mastering Java Syntax

Mr. Monroe s Guide to Mastering Java Syntax Mr. Monroe s Guide to Mastering Java Syntax Getting Started with Java 1. Download and install the official JDK (Java Development Kit). 2. Download an IDE (Integrated Development Environment), like BlueJ.

More information

Contents 8-1. Copyright (c) N. Afshartous

Contents 8-1. Copyright (c) N. Afshartous Contents 1. Classes and Objects 2. Inheritance 3. Interfaces 4. Exceptions and Error Handling 5. Intro to Concurrency 6. Concurrency in Java 7. Graphics and Animation 8. Applets 8-1 Chapter 8: Applets

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

Computer Programming, I. Laboratory Manual. Final Exam Solution

Computer Programming, I. Laboratory Manual. Final Exam Solution Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution

More information

PieNum Language Reference Manual

PieNum Language Reference Manual PieNum Language Reference Manual October 2017 Hadiah Venner (hkv2001) Hana Fusman (hbf2113) Ogochukwu Nwodoh( ocn2000) Index Introduction 1. Lexical Convention 1.1. Comments 1.2. Identifiers 1.3. Keywords

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

We now start exploring some key elements of the Java programming language and ways of performing I/O

We now start exploring some key elements of the Java programming language and ways of performing I/O We now start exploring some key elements of the Java programming language and ways of performing I/O This week we focus on: Introduction to objects The String class String concatenation Creating objects

More information

Games Course, summer Introduction to Java. Frédéric Haziza

Games Course, summer Introduction to Java. Frédéric Haziza Games Course, summer 2005 Introduction to Java Frédéric Haziza (daz@it.uu.se) Summer 2005 1 Outline Where to get Java Compilation Notions of Type First Program Java Syntax Scope Class example Classpath

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

Properties of an identifier (and the object it represents) may be set at

Properties of an identifier (and the object it represents) may be set at Properties of an identifier (and the object it represents) may be set at Compile-time These are static properties as they do not change during execution. Examples include the type of a variable, the value

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

Computer Science is...

Computer Science is... Computer Science is... Automated Software Verification Using mathematical logic, computer scientists try to design tools to automatically detect runtime and logical errors in huge, complex programs. Right:

More information

AP Computer Science Unit 1. Programs

AP Computer Science Unit 1. Programs AP Computer Science Unit 1. Programs Open DrJava. Under the File menu click on New Java Class and the window to the right should appear. Fill in the information as shown and click OK. This code is generated

More information

Strings. Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects.

Strings. Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects. Strings Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects. The Java platform provides the String class to create and

More information

Introduction to Java Applications

Introduction to Java Applications 2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use

More information