Sie sind auf Seite 1von 25

GUJARAT TECHNOLOGICAL UNIVERSITY

OBJECT ORIENTED PROGRAMMING USING JAVA


SUBJECT CODE: 2150704
B.E. 5thSEMESTER

Type of course: Core

Prerequisite: none

Rationale: Java is a general-purpose computer programming language that is a class-based, object-oriented.


It is intended to let application developers "write once, run anywhere" meaning that compiled Java code can
run on all platforms that support Java without the need for recompilation. UML (Unified Modeling
Language) is a modeling language used by software developers. UML can be used for modeling a system
independent of a platform language. UML is a graphical language for visualizing, specifying, documenting
information of software systems. UML is a standard way to write a system model that covers conceptual
ideas.

Teaching and Examination Scheme:

Teaching Scheme Credits Examination Marks Total


L T P C Theory Marks Practical Marks Marks
ESE PA (M) ESE (V) PA
(E) PA ALA ESE OEP (I)
4 0 2 6 70 20 10 20 10 20 150

Content:

Sr. No. Content Total Weightage Weig


Hrs (Out of 100%
)
1 Basics of Java: 2 5
Features of Java, Byte Code and Java Virtual Machine, JDK, Data types,
Operator, Control Statements – If , else, nested if, if-else ladders, Switch,
while, do-while, for, for-each, break, continue.
2 Array and String: 2 5
Single and Multidimensional Array, String class, StringBuffer class,
Operations on string, Command line argument, Use of Wrapper Class.
3 Classes, Objects and Methods: 6 15
Class, Object, Object reference, Constructor, Constructor Overloading,
Method Overloading, Recursion, Passing and Returning object form
Method, new operator, this and static keyword, finalize() method, Access
control, modifiers, Nested class, Inner class, Anonymous inner class,
Abstract class.
4 Inheritance and Interfaces: 6 10
Use of Inheritance, Inheriting Data members and Methods, constructor in
inheritance, Multilevel Inheritance – method overriding Handle
multilevel constructors – super keyword,Stop Inheritance - Final
keywords, Creation and Implementation of an interface, Interface
reference, instanceof operator, Interface inheritance, Dynamic method
dispatch ,Understanding of Java Object Class,Comparison between
Abstract Class and interface, Understanding of System.out.println –
statement.
5 Package: 2 3
Use of Package, CLASSPATH, Import statement, Static import, Access
control
6 Exception Handling: 5 10
Exception and Error, Use of try, catch, throw, throws and finally, Built in
Exception, Custom exception, Throwable Class.
7 Multithreaded Programming: 4 5
Use of Multithread programming, Thread class and Runnable interface ,
Thread priority, Thread synchronization, Thread communication,
Deadlock
8 IO Programming: 5 10
Introduction to Stream, Byte Stream, Character stream, Readers and
Writers, File Class, File InputStream, File Output Stream,
InputStreamReader, OutputStreamWriter, FileReader, FileWriter,
Buffered Reader
9 Collection Classes : 1 2
List, AbstractList, ArrayList, LinkedList, Enumeration, Vector,
Properties, Introuduction to Java.util package
10 Networking with java.net 2 5
InetAddress class,Socket class, DatagramSocket class, DatagramPacket
class
11 Introduction to Object orientation, Modeling as a Design Technique 1 2
Modeling Concepts ,abstraction, The three models, Class Model, State
model and Interaction model.
12 Class Modeling 3 5
Object and class concepts, link and association, Generalization and
Inheritance
13 Advanced class Modeling 3 5
Advanced Object and class concepts, Association Ends, N-ary
associations, aggregation, abstract classes, multiple inheritance,
Metadata, Constraints, Derived data, Packages.
14 State modeling 2 8
Events, states, Transition and conditions, state diagram, state diagram
behavior
15 Interaction Modeling 4 10
Use case Models, sequence models, activity models

Suggested Specification table with Marks (Theory):

Distribution of Theory Marks

R Level U Level A Level N Level E Level C Level


10 45 10 5 - -

Legends: R: Remembrance; U: Understanding; A: Application, N: Analyze and E: Evaluate C:


Create and above Levels (Revised Bloom’s Taxonomy)

Note: This specification table shall be treated as a general guideline for students and teachers. The actual
distribution of marks in the question paper may vary slightly from above table.
Reference Books:

1) Java Fundamentals A comprehensive introduction By Herbert Schildt, Dale Skrien, McGraw Hill
Education.
2) Programming with Java A Primer – E.Balaguruswamy,Mc Grawhill
3) The Complete Reference, Java 2 (Fourth Edition),Herbert Schild, - TMH.
4) Core Java Volume-I Fundamentals Horstmann & Cornell, - Pearson Education. - Eight Edition
5) Object Oriented Modeling and Design with UML
Michael Blaha and James Rambaugh – PEARSON second edition
6) UML Distilled: A Brief Guide to the Standard Object Modeling Language (3rd Edition) by Martin
Fowler

Course Outcome:

After learning the course the students should be able to:

i. Undertand object oriented programming concepts and implement in java.


ii. Comprehend building blocks of OOPs language, inheritance, package and interfaces.
iii. Identify exception handling methods.
iv. Implement multithreading in object oriented programs.
v. Prepare UML diagrams for software system

List of Experiments:

1. Write a program to convert rupees to dollar. 60 rupees=1 dollar.


2. Write a program that calculate percentage marks of the student if marks of 6 subjects are given.
3. Write a program to enter two numbers and perform mathematical operations on them.
4. Write a program to find length of string and print second half of the string.
5. Write a program to accept a line and check how many consonants and vowels are there in line.
6. Write a program to count the number of words that start with capital letters.
7. Write a program to find that given number or string is palindrome or not.
8. Create a class which ask the user to enter a sentence, and it should display count of each vowel type
in the sentence. The program should continue till user enters a word “quit”. Display the total count
of each vowel for all sentences.
9. Write an interactive program to print a string entrered in a pyramid form. For instance, the string
“stream” has to be displayed as follows:
S
St
S t r
S t r e
S t r e a
S t r e a m
10. Write an interactive program to print a diamond shape. For example, if user enters the number 3,
the diamond will be as follows:
*
**
** *
**
*
11. Create a class called Student. Write a student manager program to manipulate the student
information from files by using FileInputStream and FileOutputStream
12. Refine the student manager program to manipulate the student information from files by using the
BufferedReader and BufferedWriter
13. Refine the student manager program to manipulate the student information from files by using the
DataInputStream and DataOutputStream. Assume suitable data
14. Prepare a class diagram for given group of classes using multiplicity, generalization, association
concepts. And add at least 5-7 attributes and 3-5 operations for particular class Page, Shape, Point,
Line, Arc, Ellipse, Rectangle, Circle
15. Prepare a class diagram for given group of classes using multiplicity, generalization,
association concepts. And add at least 5-7 attributes and 3-5 operations for particular class. City,
Airport, Airline, Pilot, Flight, Plane, Seat, Passenger
16. Categorize the following relationships into generalization, aggregation or association.
[A] A country has a capital city
[B] A dining philosopher uses a fork
[C] A file is an ordinary file or a directory file
[D] Files contains records
[E] A polygon is composed of an ordered set of points
[F] A drawing object is text, a geometrical object, or a group
[G] A person uses a computer language on a object
[H] Modems and keyboards are input/output devices
[I] Classes may have several attributes
[J] A person plays for a team in a certain year
[K] A route connects two cities
[L] A student takes a course from a professor
17. Prepare a state diagram for an interactive diagram editor for selecting and dragging objects
18. Prepare a use case diagram and sequence diagram for a computer email system
19. Prepare an activity diagram for computing a restaurant bill, there should be charge for each
delivered item. The total amount should be subject to tax and service charge of 18% for group of
six and more. For smaller groups there should be a blank entry. Any coupons or gift certificates
submitted by the customer should be subtracted
20. Prepare a sequence diagram for issuing a book in the library management system

Design based Problems (DP)/Open Ended Problem:


1) Remove duplicate lines from a large text or given document.
2) Write a program to compute if one string is a rotation of another. For example, pit is rotation of tip
as pit has same character as tip.

Major Equipment:

Computer ,Laptop

List of Open Source Software/learning website:

i. Java Development Kit:


http://www.oracle.com/technetwork/java/javase/downloads/index.html
ii. http://docs.oracle.com/javase/specs/jls/se7/html/index.html
iii. http://docs.oracle.com/javase/tutorial/java/index.html
iv. http://www.javatpoint.com/
v. http://www.tutorialspoint.com/java/
vi. http://www.learnjavaonline.org/
vii. http://www.c4learn.com/javaprogramming/
viii. http://www.learn-java-tutorial.com/
ix. http://www.tutorialspoint.com/uml/
x. http://www.uml.org/
ACTIVE LEARNING ASSIGNMENTS: Preparation of power-point slides, which include videos,
animations, pictures, graphics for better understanding theory and practical work – The faculty will allocate
chapters/ parts of chapters to groups of students so that the entire syllabus to be covered. The power-point
slides should be put up on the web-site of the College/ Institute, along with the names of the students of the
group, the name of the faculty, Department and College on the first slide. The best three works should
submit to GTU.
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V (NEW) - EXAMINATION – SUMMER 2017
Subject Code: 2150704 Date: 27/04/2017
Subject Name: Object Oriented Programming
Time: 02:30 PM to 05:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER–V(New) • EXAMINATION – WINTER 2016
Subject Code:2150704 Date:17/11/2016
Subject Name:Object Oriented Programming using JAVA
Time: 10:30 AM to 01:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
MARKS
Q.1 Short Questions 14
1 Explain role of JVM.
2 The method main is a static method. Why?
3 Explain keyword this.
4 How do you interpret following statement?
String [] s;
5 Explain right-shift operators.
6 Write two usage of keyword super.
7 Describe use of CLASSPATH.
8 Explain keyword volatile.
9 Explain method parseInt.
10 List two characteristics of an abstract class.
11 Write use of keyword import.
12 Explain ArrayList.
13 Explain multiplicity.
14 Explain association class.
Q.2 (a) Compare String and StringBuffer. 03
(b) Explain keyword final by giving examples. 04
(c) Declare a class called Book having book title & author name as 07
members. Create a sub-class of it, called BookDetails having
price & current stock of book as members. Create an array for
storing details of n books. Define methods to achieve following:
- Initialization of members
- To query availability of a book by author name / book title
- To update stock of a book on purchase and sell
Define method main to show usage of above methods.
OR
(c) It is required to compute SPI (semester performance index) of n 07
students of a class for their registered subjects in a semester.
Assume that all students register for 6 subjects and each subject
carry 5 credits. Also, follow GTU convention and method for
computation of SPI.
Declare a class called student having following data members:
id_no, grades_obtained and spi.
Define constructor, display and calculate_spi methods. Define
main to process data of n students
Q.3 (a) Explain keywords private and protected. 03
(b) Define a recursive method for computing x raised to power y by 04
doing repetitive multiplication where x and y are positive integer
numbers. Define main to use above method.
(c) It is required to maintain and process the status of total 9 07
resources. The status value is to be stored in an integer array of
dimension 3x3. The valid status of a resource can be one of the
1
followings:
free: indicated by integer value 0
occupied: indicated by integer value 1
inaccessible: indicated by integer value 2
Declare a class called ResourcesStatus, having data member
called statusRef, referring to a two dimensional array (3x3) of
integers to be used to refer to the above mentioned status values.
Define a member method called processStausCount that counts
and displays total number of free resources, total number of
occupied resources and total number of inaccessible resources.
The exception to be raised and handled if total number of
occupied resources exceeds total number of free resources. The
handler marks status of all inaccessible resources as free.
Accept initial status values from command line arguments and
initialize the array. Raise and handle user defined exception if
invalid status value given.
OR
Q.3 (a) Explain interface with help of example(s). 03
(b) Write a method for computing first n terms of Fibonacci 04
sequence. Define method main taking value of n as command
line argument and calling the method.
(c) Write a complete program to accept N integer numbers from the 07
command line. Raise and handle exceptions for following cases :
- when a number is –ve
- when a number is evenly divisible by 10
- when a number is greater than 1000 and less than 2000
- when a number is greater than 7000
Skip the number if an exception is raised for it, otherwise add it
to find total sum.
Q.4 (a) Explain instanceof operator. 03
(b) Write a multithreaded program to compute and print prime 04
numbers up to n where n is given as command line argument.
Instantiate requited number of threads where each thread except
the last, examines next 50 numbers and the last thread examines
remaining numbers to check whether a number is a prime or not.
(c) Write a complete program to read from console up to n lines or 07
until “quit” is entered. The lines entered are displayed on the
screen after reading all lines. The program also counts lines
beginning with character ‘A’ or ‘E’ as first letter.
OR
Q.4 (a) Explain dynamic method dispatch by giving an example. 03
(b) Write a complete multi threaded program to meet following 04
requirements for producer-consumer threads:
- Three threads – one producer and two consumers to be
instantiated in the method main.
- At a time, the producer produces one integer information
along with consumer_id to represent id of a consumer that
will consume produced information.
- Information and consumer_id are stored in a shared buffer.
- The information produced is to be consumed by
appropriate consumer only, as specified by the producer.
- The producer thread produces total 6 information.
(c) (i) Explain usage of class FileInputStream by giving an example. 07
(ii) Explain InetAddress class and its one method.
Q.5 (a) Explain Aggregation and Association. 03

2
(b) Prepare a class model to describe undirected graph. An 04
undirected graph consists of a set of vertices and a set of edges.
Edges connect pairs of vertices. Your model should capture only
structure of graphs (i.e. connectivity) and need not be concerned
with layout such as location of vertices or lengths of edges.
(c) Explain activity diagram with the help of an example. 07
OR
Q.5 (a) Explain Metadata with the help of an example. 03
(b) Construct state diagram for a telephone line. 04
(c) Explain sequence diagram with the help of an example. 07

*************

3
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V (NEW) - EXAMINATION – SUMMER 2016
Subject Code:2150704 Date:06/05/2016
Subject Name:Object Oriented Programming using JAVA
Time:02:30 PM to 05:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) Explain features of Java. 07


(b) Explain Thread life cycle and describe creation of thread with suitable example. 07
Q.2 (a) Differentiate between Method overloading and Method overriding. 07
(b) Explain following with example: 07
i) Finalize() ii) static iii) super iv) final
OR
(b) The abstract vegetable class has three subclasses named Potato, Brinjal and 07
Tomato. Write a java prog. That demonstrates how to establish this class
hierarchy. Declare one instance variable of type String that indicates the color
of a vegetable. Crete and display instances of these objects. Override the
toString() method of object to return a string with the name of vegetable and its
color.
Q.3 (a) Describe Inheritance and its type with suitable example. 07
(b) Explain use of Interface with suitable example. 07
OR
Q.3 (a) Write a method for computing xy doing repetitive multiplication. X and y are of 07
type integer and are to be given as command line arguments. Raise and handle
exception(s) for invalid values of x and y.
(b) Differentiate between interface and abstract class 07
Q.4 (a) List out the steps of preparing domain class model. What are the criteria for 07
identifying right classes?
(b) What do you mean by an event in state diagram? Discuss various types of 07
events.
OR
Q.4 (a) What do you mean by object-orientation? Briefly discuss the characteristics of 07
object oriented approach.
(b) Explain various steps required for class design. 07
Q.5 (a) Prepare a sequence diagram for issuing book in the library management system. 07
(b) Explain ‘ordered’, ‘bags’, ‘sequences’ in class diagram with suitable examples. 07
OR
Q.5 (a) Explain Nested States. Draw the Nested states diagram for the phone line. 07
(b) Define the following terms: 07
Aggregation, Abstract Class, Generalization, Reification, Constraints, Package,
Metadata.

*************

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE – SEMESTER – V (NEW) EXAMINATION – WINTER 2015

Subject Code: 2150704 Date:05/12/ 2015


Subject Name:Object Oriented Programming using JAVA
Time:10:30am to 1:00pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) Write a program that creates and initializes a four integer 07
element array. Calculate and display the average of its
values.
(b) Write a java program to do sum of command line argument 07
passed two Double numbers.

Q.2 (a) Define time class with hour and minute. Also define 07
addition method to add two time objects.
(b) Explain use of Linked List collection class with example. 07
OR
(b) Write a program to create circle class with area function to 07
find area of circle.

Q.3 (a) With example explain use of finally in exception handling. 07


(b) Write an application that searches through its command- 07
line argument. If an argument is found that does not begin
with and upper case letter, display error message and
terminate.
OR
Q.3 (a) Explain garbage collection and finalize method in JAVA. 07
(b) Explain use of throw in exception handling with example. 07

Q.4 (a) Explain constructor overloading using example. 07


(b) Explain multi threading in java using example. 07
OR
Q.4 (a) Explain method overriding with example. 07
(b) Write an application that reads a file and counts the 07
number of occurrences of digit 5. Supply the file name as a
command-line argument.

Q.5 (a) Draw use case diagram for Library Management System. 07
(b) Draw class diagram for online restaurant system. 07
OR
Q.5 (a) Draw sequence diagram for book issue process of library. 07
(b) Draw class diagram for ATM. 07

*************

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V (OLD) - EXAMINATION – SUMMER 2017
Subject Code: 150704 Date: 27/04/2017
Subject Name: Object Oriented Programming With Java
Time: 02:30 PM to 05:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) What is Thread? Draw and explain life cycle of thread. 07
(b) Explain Runtime Polymorphism with example 07
Q.2 (a) Explain inheritance with its types and example. 07
(b) Write a java program to print prime number upto 100. 07
OR
(b) Write a java program which check whether entered number is prime or 07
not ?
Q.3 (a) What is package? List various built in package used in java. 07
(b) Read employee salary and calculate the income tax based on 10% of 07
income and store it in tax.txt file for five different employees.
OR
Q.3 (a) What is collection in Java? Differentiate between Vector and Array List. 07
(b) Name three types of layout managers and briefly explain their operations. 07
Q.4 (a) Discuss public, private, protected and default access modifier with 07
example.
(b) Explain following key words: this, super, instance of, static. 07
OR
Q.4 (a) Write a java program which read numbers from number.txt file and store 07
even number to even.txt and odd number into odd.txt file.
(b) What is an Exception? Explain Exception handling in JAVA. 07
Q.5 (a) Write a java network example to print server date and time on client 07
machine.
(b) Differentiate Abstract class and interface with suitable example. 07
OR
Q.5 (a) Write an application that read limit from user and executes two threads. 07
One thread displays total of first n even numbers & another thread
displays total of first n odd numbers. Create the threads by implementing
the Runnable interface.
(b) Write a program to check that whether the name given from command line 07
is file or not? If it is a file then print the size of file and if it is directory then
it should display the name of all files in it.

*************

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V- EXAMINATION – SUMMER 2016
Subject Code: 150704 Date: 06/05/2016
Subject Name: Object Oriented Programming With Java
Time: 02:30 PM to 05:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) Explain use of final, static and super keyword by giving examples. 07
(b) Explain method overriding and method overloading with the help of 07
examples.

Q.2 (a) Explain : Abstract Class and Interface with example. Compare Both. 07
(b) Differentiate the followings: 07
i) Applet and Application
ii) String class and StringBuffer class
iii) Constructor and Method
OR
(b) Define generics in java. Write a program to demonstrate generic 07
interface and generic method.

Q.3 (a) What is collection in Java? Differentiate between Vector and ArrayList. 07
(b) What is Wrapper class in Java? Explain with examples. 07
OR
Q.3 (a) Draw and explain lifecycle of Applet. 07
(b) Explain wait, notify, notifyall, synchronized methods in thread. 07

Q.4 (a) Draw and explain life cycle of Thread. Also list and explain various 07
methods of thread.
(b) What is package? Explain steps to create package with example. 07
OR
Q.4 (a) What is inheritance in java? Explain different types of inheritance with 07
proper example partial code.
(b) Describe abstract class called Shape which has three subclasses say 07
Triangle, Rectangle and Circle. Define one method area() in the abstract
class and override this area() in these three subclasses to calculate area
for specific class’ object.

Q.5 (a) What is Exception? Explain various Built-in exceptions in java. Also 07
give difference between throw and throws keywords.
(b) Write a Java program to copy content of file1.txt to file2.txt using Java 07
file handling.
OR
Q.5 (a) Explain Event Handling in java and describe methods of mouse event 07
and key event.
(b) Write a program to create two threads, one thread will print odd 07
numbers and second thread will print even numbers between 1 to 100
numbers.
*************
1/1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V EXAMINATION – WINTER 2015

Subject Code: 150704 Date:05/12/2015


Subject Name: Object Oriented Programming with Java
Time: 10:30am to 1:00pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) (i) Explain short circuited operators. 07


(ii) Explain function overloading with an example.
(b) (i) Explain final and finally. 07
(ii) Explain array implementation in Java.
Q.2 (a) Declare a class called Coordinate to have 3 dimensional Cartesian coordinates. 07
Define following methods :
- Constructor(s)
- add_coordinates to add two Coordinate objects and to produce resultant
object. Generate and handle exception if all three coordinates of the
resultant Coordinate object are zero.
Define method main to show use of above methods.
(b) (i) Explain with the help of example(s), use of interface. 07
(ii) Explain packages.
OR
(b) (i) Explain keywords - super and throws. 07
(ii) Method main is a public static method. Justify.
Q.3 (a) Declare a class called author having author_name as private data member. Extend 07
author class to have two sub classes called book_publication &
paper_publication. Each of these classes have private member called title. Show
usage of dynamic method dispatch (dynamic polymorphism) to display book or
paper publications of a given author. Use command line arguments for inputting
data.
(b) (i) Explain instanceof operator. 07
(ii) There is no destructor in Java. Justify.
OR
Q.3 (a) (i) Java program is to be compiled first and then to be interpreted for execution. 07
True or false? Justify your answer.
(ii) Explain event handling in Java.
(b) (i) Explain keywords this and protected. 07
(ii) Explain keywords abstract and volatile.
Q.4 (a) (i) Explain use of adapter classes. 07
(ii) Explain utility class ArrayList.
(b) (i) Explain life cycle of an applet. 07
(ii) Explain Flow layout.
OR
Q.4 (a) Write a complete program to have 3 Buttons in a frame having exit capabilities. 07
Buttons are to be added in the frame as per the layout of your choice. Count and
display number of times each Button being clicked.
1
(b) Write a complete program to implement a singly linked list with nodes storing 07
integer information using suitable utility class.
Q.5 (a) Write a multithreaded program to print all odd positive numbers in ascending 07
order up to n, where n is a positive integer number given as a command line
argument. Instantiate requited number of threads, where each thread except the
last, examines next 50 numbers and the last thread examines remaining numbers
up to n.
(b) (i) Compare methods wait and sleep. 07
(ii) Explain Runnable and notifyAll.
OR
Q.5 (a) Write a multi-threaded program to have two producer threads, each writes (push) 07
total 7 integer items to the same (common) stack. The producers enter into sleep
state for 500 ms after writing every item. There is one consumer thread that reads
(pop) from the same stack and enters into sleep state then-after for 600 ms.
Assume stack size as 10. Incorporate all required conditions so that all valid items
are popped only once and there is no stack overflow & underflow.
(b) (i) Explain method join with the help of an example. 07
(ii) Explain two usage of keyword synchronized.

*************

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER– V EXAMINATION – SUMMER 2015

Subject Code: 150704 Date: 07/05/2015


Subject Name: Object Oriented Programming With Java
Time:02.30pm-05.00pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) List various features of Java? Also explain any two feature with example. 07
(b) Compare Object oriented programming with sequential programming. 07
Q.2 (a) What is visibility modifier? Explain all with example. 07
(b) What is package? List various built in package used in java. 07
OR
(b) What is Thread? Draw and explain life cycle of thread. 07
Q.3 (a) Write a program which shows an example of function overloading? 07
(b) What is error? Explain various types of errors. How can we handle run time 07
errors in java?
OR
Q.3 (a) Write a program which shows an example of function overriding? 07
(b) Compare String with StringBuffer class. 07
Q.4 (a) What is variable? How can we define variable in java? Also list rules for valid 07
variable names.
(b) What is constructor? What are the rules for creating constructor in java? 07
OR
Q.4 (a) Explain inheritance with its types and example. 07
(b) How interface are useful in java? Explain with example. 07
Q.5 (a) What are final class, final function and final variable in java? Explain with 07
example.
(b) Explain following key words: this, super, instance of 07
OR
Q.5 (a) Compare Java Applets with application programs. 07
(b) How can we open and read a text file in java? Explain your answer with 07
example.

*************

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V • EXAMINATION – WINTER • 2014
Subject Code: 150704 Date: 01-12-2014
Subject Name: Object Oriented Programming with Java
Time: 10.30 am - 01.00 pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) Describe the following features of java: 07


1)Multithreaded,2)Architecture-neutral 3)Interpreted 4)High performance
5) Distributed 6) Portable 7) Dynamic
(b) Differentiate between Method overloading and method overriding with 07
example.
Q.2 (a) Explain the followings with example 07
Dynamic Method Dispatch , this, super, final
(b) Write a program to demonstrate the multipath inheritance for the classes 07
having relations as shown in figure 1.

Figure 1

OR
(b) Write a program that illustrates interface inheritance. Interface A is extended 07
by A1 and A2. Interface A12 inherits from both P1 and P2.Each interface
declares one constant and one method. Class B implements A12.Instantiate B
and invoke each of its methods. Each method displays one of the constants
Q.3 (a) What are the benefits of using generic types? 03
(b) Differentiate between abstract class and interface. 04
(c) Discuss public, private, protected and default access modifier with example. 07
OR
Q.3 (a) What is collection in Java? Differentiate between Vector and Array List. 07
(b) Justify statement. 07
(i) JVM is platform dependent.
(ii) There is no destructor in Java.

1
Q.4 (a) Write a simple GUI application that traces the user’s action such 07
Keyboard action.
(b) Write a program to replace all “word1” by “word2” from a file1, and output is 07
written to file2 file and display the no. of replacement.
OR
Q.4 (a) Create an applet which has a Text Field to accept a URL string, and displays 07
the document of the URL string in a new browser window.
(b) Differentiate String class and StringBuffer class with explanation of its 07
methods.
Q.5 (a) Write a program to create two threads, one thread will print odd numbers and 07
second thread will print even numbers between 1 to 20 numbers.
(b) Write a program that counts number of characters, words, and lines in a file. 07
Use exceptions to check whether the file that is read exists or not.
OR
Q.5 (a) Explain the following terms with respect to exception handling. 07
i) try ii) catch iii) throw iv) finally
(b) What is a thread? Describe the complete life cycle of thread with example. 07

*************

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V • EXAMINATION – SUMMER • 2014
Subject Code: 150704 Date: 17-06-2014
Subject Name: Object Oriented Programming with Java
Time: 10.30 am - 01.00 pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
Q.1 (a) Explain features of JAVA. 07
(b) What is constructor? Explain constructor overloading with example. 07
Q.2 (a) What is Multithreading ? Explain Life Cycle of Thread with example. 07
(b) Explain following with example: 07
1. Super keyword.
2. Final keyword
OR
(b) Explain Following: 07
1. Garbage Collection
2. Short Circuit Operators.
Q.3 (a) Explain Dynamic method dispatch with proper example. 07
(b) Explain package and interface with Example. 07
OR
Q.3 (a) What is an Exception? Explain Exception handling in JAVA. 07
(b) Explain thread Synchronization with join() and isAlive() methods. 07
Q.4 (a) Answer Following: 07
1. Benefits of Generic types.
2. Explain Java Beans.
(b) Explain Delegation Event model. Also Explain use of Adapter class. 07
OR
Q.4 (a) Differentiate the following: 07
1. Text I/O v/s Binary I/O.
2. String class v/s StringBuffer class.
(b) Explain life cycle of Applet. Create a simple Applet having a message “Hello”. 07
Q.5 (a) Create an applet having a circle which is moving from left to right and reflected 07
back from right to left continuously.
(b) Explain Layout Manager. 07
OR
Q.5 (a) Create an applet that having three scroll bars for three colors red, green and blue 07
with minimum 0 and maximum 255 values. The background color of applet
changes depending on the value of the scroll bar at that time.
(b) Answer following: 07
1. Collection in JAVA.
2. Features of Map Interface.

*************

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V • EXAMINATION – WINTER 2013
Subject Code: 150704 Date: 02-12-2013
Subject Name: Object Oriented Programming with Java
Time: 10.30 am - 01.00 pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
Q.1 (a) List and explain various features of java. 07
(b) Explain the words super, static, final and this with the help of example. 07

Q.2 (a) Explain constructor and finalizer with the help of example. 07
(b) Compare String with StringBuffer. Also write a program to count occurrence 07
of character in a string.
OR
(b) Compare List, Set and Map interfaces. Also compare ArrayList, TreeSet and 07
HashMap classes in java.

Q.3 (a) Explain Overloading and Overriding with example. 07


(b) What is Layout? Explain various Layout Managers in java. 07
OR
Q.3 Write a note on (Any two) 14
(a) JavaBeans
(b) Swing in JAVA
(c) Network programming in Java

Q.4 (a) Draw and explain lifecycle of Applet. 07


(b) Write a program to count the total no. of chars, words, lines, alphabets, digits, white 07
spaces in a given file.
OR
Q.4 (a) Draw and explain life cycle of thread. Also list and explain various methods of 07
thread.
(b) Write a java application that has three Buttons labeled Red, Green, Blue & on 07
clicking the background color should change accordingly & have a label displaying
the color selected.

Q.5 (a) What is Exception? Give some of Built-in exceptions in java. Also give difference 07
between throw and throws.
(b) Write an application that creates and starts three threads. Each thread is instantiated 07
from the same class. It executes a loop with 10 iterations. Each iteration displays
string "HELLO", sleeps for 300 milliseconds. The application waits for all the threads
to complete & displays the message "Good Bye...".
OR
Q.5 (a) What is package? Explain steps to create package with example. 07
(b) Write an application that executes two threads. One thread displays "Good Morning" 07
every 1000 milliseconds & another thread displays "Good Afternoon" every 3000
milliseconds. Create the threads by implementing the Runnable interface.

*************

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–V • EXAMINATION – SUMMER 2013
Subject Code: 150704 Date: 20-05-2013
Subject Name: Object Oriented Programming with Java
Time: 10.30 am - 01.00 pm Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) List OOP characteristics and describe inheritance with examples. 07
(b) Explain & illustrate by examples use of final, finally and method finalize. 07

Q.2 (a) Declare a class called coordinate to represent 3 dimensional Cartesian 07


coordinates( x, y and z). Define following methods:
- constructor
- display, to print values of members
- add_coordinates, to add three such coordinate objects to produce a
resultant coordinate object. Generate and handle exception if x, y
and z coordinates of the result are zero.
- main, to show use of above methods.
(b) Explain short circuited operators, shift operators and this reference. 07
OR
(b) Explain packages, their use, adapter classes and their needs & 07
applications. Give examples.

Q.3 (a) Declare a class called book having author_name as private data 07
member. Extend book class to have two sub classes called
book_publication & paper_publication.
Each of these classes have private member called title. Write a complete
program to show usage of dynamic method dispatch (dynamic
polymorphism) to display book or paper publications of given author.
Use command line arguments for inputting data.
(b) (i) Explain super, instanceof and volatile. 07
(ii) Compare byte streams and character streams.
OR
Q.3 (a) It is required to compute SPI (semester performance index) of n 07
students of your college for their registered subjects in a semester.
Declare a class called student having following data members:
id_no , no_of_subjects_registered, subject_code , subject_credits,
grade_obtained and spi.
- Define constructor and calculate_spi methods.
- Define main to instantiate an array for objects of class student to
process data of n students to be given as command line
arguments.
(b) (i) JVM is platform dependent. Justify. 07
(ii) There is no destructor in Java. Justify.

Q.4 (a) Write a complete GUI based program to implement a queue of strings 07
in an applet. Select components and layout of your choice.

1/2
Q.4 (b) (i) Illustrate by example – generic programming. 07
(ii) Explain interface and its usage.
OR
Q.4 (a) Write a complete program to have a GUI based simple calculator in a 07
frame supporting addition & subtraction. There are buttons for 0 to 9
digits and for arithmetic operations. Select layout of your choice.
(b) Explain 07
(i) card layout
(ii) utility class Hashtable with example.

Q.5 (a) Write a complete multi-threaded program to meet following 07


requirements:
o Two threads of same type are to be instantiated in the method
main.
o Each thread acts as a producer as well as a consumer.
o A shared buffer can store only one integer information along with
the source & destination of the information at a time.
o The information produced is to be consumed by appropriate
consumer.
o Both producers produce information for both consumers.
o Each thread produces 5 information.
(b) Explain life cycle of an applet. Also illustrate how to provide 07
parameters to applet through html.
OR
Q.5 (a) It is required to add two MxN sized matrices having integer elements to 07
produce a third resultant matrix of size MxN.
Write a complete multi-threaded program to meet following
requirements:
- Accept all required arguments from the command line.
- Instantiate M threads – with id 0 to M -1 respectively, each thread
performing addition of elements on the row specified by its id to
produce corresponding row of the resultant matrix.
(b) Explain wait, notify, synchronized and native methods. 07

*************

2/2