0% found this document useful (0 votes)
46 views

Oops

Uploaded by

220170107139
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Oops

Uploaded by

220170107139
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Seat No.: ________ Enrolment No.

___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–IV (NEW) EXAMINATION – WINTER 2023
Subject Code:3140705 Date:31-01-2024
Subject Name: Object Oriented Programming -I
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.
4. Simple and non-programmable scientific calculators are allowed.
MARKS

Q.1 (a) How java supports platform independency? What is the role of JVM in it? 03
(b) Write a program which displays first n prime number? Where is n provided 04
by user as command line argument?
(c) Write a program which declare integer array of 10 elements? Initialize array 07
and define following methods with the specified header:
(i) public static int add(int [] array) print addition of all element of array.
(ii) public static int max(int [] array) print maximum element of array.
(ii) public static int search(int [] array, int key) search element key in array
and return index of it. If element is not found method will return -1.

Q.2 (a) Describe the relationship between an object and its defining class? 03
(b) Analyze following code. Validate and explain output of code. If any error 04
exists, indicate portion. Suggest code to eliminate error:
public class Circle {
private double radius;
public static void main(String args[]){
Circle c1=new Circle(2);
System.out.println("Area "+c1.getArea());
B b1=new B(2, 2);
System.out.println("Area "+b1.getArea());
}
public Circle(double radius) {
radius = radius;
}
public double getRadius() {
return radius;
}
public double getArea() {
return radius * radius * Math.PI;
}
}

class B extends Circle {


private double length;
B(){}
B(double radius, double length) {
length = length;
}
public double getArea() {
return (super.getArea() * length);
}
}
(c) Design a java class Rectangle which contains following field and methods: 07
(i) Field: length, width: int
(ii) Default Constructor: initialize all fields with 0 value
(iii) Method: int getArea() will return area of rectangle.

1
OR
(c) Answer in brief(within two lines): 07
(i) If a method defined in a subclass has the same signature as a method in its
superclass with the
same return type, is the method overridden or overloaded?
(ii) How do you invoke an overridden superclass method from a subclass?
(iii) What is the purpose of "this" keyword?
(iv) Differentiate between following statements:
int a=3;
Integer b=new Integer(3);
(v) Which java keyword is used to prevent inheritance (prevent class to be
extended)?
(vi) Can we create reference of interface. If we can create, then what is the
use of it?
(vii) What is the difference between a String in Java and String in C/C++?

Q.3 (a) Discuss benefits of multithreading? 03


(b) Develop a program which stores name of districts in Gujrat in array of String. 04
The array specified capacity to store 5 districts. The user will be able to print
name of district based on array index e.g. (0 will print Ahemdabad). If the
specified index is out of bounds, program will display the message Out of
Bounds.
(c) Characterize the two ways of implementing thread in Java? Illustrate each 07
method by example?
OR
Q.3 (a) Explain the use of finally. Show the type of code usually kept in finally? 03
(b) Distinguish unchecked exception and checked exception? Give example of 04
each type of exception?
(c) Implement java code to take some (say 10) Strings from users. Put all the 07
input Strings in an array (String name[]). Provide implementation of
following methods:
(i)search(String s) will return index of String passed in method if String S is
found in name, otherwise return -1.
(ii)sort() will print sorted String array to user

Q.4 (a) Write a program to find out whether the given number is palindrome or not? 03
(b) Outline the use of throw in exception handling with example. 04
(c) Give Definitions: static, finalize, final 07
OR
Q.4 (a) Elaborate the role of java garbage collector. 03
(b) State four similarities between Interfaces and Classes. 04
(c) Differentiate between ArrayList and LinkedList? Which list should you use 07
to insert and delete elements at the beginning of a list? What methods are in
LinkedList but not in ArrayList?

Q.5 (a) List various classes for Binary Input Output? 03


(b) Characterize the role of Iterator interface? 04
(c) Explain DataInputStream and DataOutputStream Classes? Implement a java 07
program to demonstrate any one of them?
OR
Q.5 (a) What do you understand by JavaFX? How it is different from AWT? 03
(b) Explain ArrayList Class with its methods? 04
(c) Design and develop EMI Calculator using JavaFX? The user will enter a loan 07
amount, annual interest
2
rate, and number of years and click the Calculate button to get EMI and total
payment ? formula is
EMI= P*r*(1+r)n/((1+r)n-1)
P is Principal Loan Amount
r is rate of interest calculated on monthly basis. (i.e., r = Rate of Annual
interest/12/100. If rate of interest is 10.5% per annum, then r =
10.5/12/100=0.00875)
n is loan term / tenure / duration in number of months?

***********

3
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER– IV(NEW) EXAMINATION – SUMMER 2023
Subject Code:3140705 Date:25-07-2023
Subject Name:Object Oriented Programming -I
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.
4. Simple and non-programmable scientific calculators are allowed.

MARKS
Q.1 (a) What is the Java bytecode, and what is the extension of Java bytecode file? 03
Which software is needed to run Java bytecode?
(b) Describe syntax errors (compile errors), runtime errors, and logic errors by 04
giving suitable examples?
(c) Answer in brief (within 50 words): 07
I. Justify Java enables high performance.
II. Differentiate between while and do while loop?
III. How many times is the println statement executed?
for (int i = 0; i < 10; i++)
for (int j = 0; j < i; j++)
System.out.println(i * j);
IV. If the value of variable x is 1 then what will be returned by the
following expression:
x%2==0
Q.2 (a) What is the use of this keyword? How it is different from super keyword? 03
(b) (i) Given that Thing is a class, how many objects and how many reference 04
variables are created by the following code?
Thing item, stuff;
item = new Thing();
Thing entity = new Thing();
(ii) Examine following code. Write and justify output.
public class MyClass {
public static void main(String[] args) {
C c = new C();
System.out.println(c.max(12, 29));
}
}
class A {
int max(int x, int y) { if (x>y) return x; else return y; }
}
class B extends A{
int max(int x, int y) { return super.max(y, x) - 10; }
}
class C extends B {
int max(int x, int y) { return super.max(x+10, y+2); }
}
(c) Write a program that defines class named StopWatch. The class contains: 07
• Private data fields startTime and endTime with getter methods.
1
• no-arg constructor that initializes startTime with the current time.
• A method named start() that resets the startTime to the current time.
• A method named stop() that sets the endTime to the current time.
• A method named getElapsedTime() that returns the elapsed time for
the stopwatch in milliseconds.
• Declare object of StopWatch to demonstrate stop watch.
Hint: Use System.currentTimeMillis() to get current time in milliseconds.
OR
(c) Create a class called Employee that includes: 07
I. Three instance variables— id (type String), name (type String) and
monthly_salary (double).
II. A default constructor that initializes the three instance variables.
III. A setter and a getter method for each instance variable (for example
for id variable void setId(String id), String getId( )).
IV. displayEmployee() method for displaying employee details.
Write a driver class named EmployeeTest that demonstrates class Employee’s
capabilities. Create two Employee objects and display each object’s yearly
salary. Then give each Employee a 10% raise and display each Employee’s
yearly salary again.

Q.3 (a) Differentiate between checked and unchecked exception? 03


(b) Exemplify throw and throws clause of exception handling? 04
(c) Demonstrate use of try catch block by catching ArithmeticExceptions and 07
InputMismatchExceptions?
OR
Q.3 (a) Describe thread life cycle with block diagram? 03
(b) Differentiate between Thread class and Runnable interface for implementing 04
Threads?
(c) Write a program to make calculator that accepts input from commandline? 07
Use java’s exception handling mechanism to handle abnormal situation?

Q.4 (a) Define Queue interface of java collection classes? 03


(b) Explain types of polymorphism? 04
(c) What are the differences between ArrayList and LinkedList? Demonstrates 07
use of ArrayList with example?
OR
Q.4 (a) Define Object Serialization? 03
(b) What are the differences between text I/O and binary I/O? 04
(c) Describe and demonstrate Binary I/O classes of java? 07

Q.5 (a) Answer in one line: 03


(i) Write the name of package in which all collection classes and interface are
grouped.
(ii) Write the name of collection interface or abstract class which store and
process object in a first-in, first-out fashion.
(iii) Write the name of method that checks whether the collection contains the
specified element.
(b) List JavaFX UI controls? 04
(c) What do you understand by event source and event object? Explain how to 07
register an event handler object and how to implement a handler interface?
OR
Q.5 (a) Enlist various Layout panes available in JavaFX? 03
(b) Discuss JavaFX benefits? 04
(c) Illustrate basic structure of JavaFX program? 07
*************
2
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER– IV EXAMINATION – SUMMER 2020
Subject Code: 3140705 Date:26/10/2020
Subject Name: Object Oriented Programming -I
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 (a) Explain JRE, JDK and JIT. 03
(b) Explain static keyword with example. 04
(c) Explain inheritance with its types and give suitable example. 07

Q.2 (a) Compare object-oriented programming with sequential programming. 03


(b) Method main is a public static method. Justify 04
(c) Write a program, which shows an example of function overloading. 07
Also, differentiate between function overloading and overriding.
OR
(c) Write a program to take string input as command line argument. In 07
addition, count occurrence of each character in a given string.
Q.3 (a) Write difference between String class and StringBuffer class. 03
(b) Explain super keyword with example. 04
(c) 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 for
specific object i.e. area() of Triangle subclass should calculate area of
triangle likewise for Rectangle and Circle.
OR
Q.3 (a) How can we protect sub class to override the method of super class? 03
Explain with example.
(b) Define Interface and explain how it differs from the class. 04
(c) What do you mean by run time polymorphism? Write a program to 07
demonstrate run time polymorphism.
Q.4 (a) Differentiate between Text I/O and Binary I/O. 03
(b) Explain ArrayList class. 04
(c) What is an Exception? List out various built-in exceptions in JAVA and 07
explain any one Exception class with suitable example.
OR
Q.4 (a) How do you declare a generic type in a class? Explain. 03
(b) Write a JAVA program to read student.txt file and display the content. 04
(c) Explain Thread life cycle in detail. Write a program to create a child 07
thread to print integer numbers 1 to 10.
Q.5 (a) Explain in brief: Color class and its methods. 03
(b) What method do you use to obtain an element in the collection from an 04
iterator? Explain with example.
(c) Enlist various layout panes and explain any two in detail. 07
OR
Q.5 (a) Compare Set and List interfaces. 03
(b) Write importance of JAVAFX compare to AWT and Swing. 04
(c) How do you create a Scene object? How do you set a scene in a stage? 07
Is it possible to create multiple scenes? Write a program to place a circle
in the scene and fill circle with red color.

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–IV (NEW) EXAMINATION – SUMMER 2021
Subject Code:3140705 Date:11/09/2021
Subject Name:Object Oriented Programming -I
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.
4. Simple and non-programmable scientific calculators are allowed.

MARKS
Q.1 (a) Define object oriented concepts. 03
(b) What is the difference between the StringBuffer and StringBuilder 04
classes?
(c) Define constructor. How objects are constructed? Explain constructor 07
overloading with an example.

Q.2 (a) Explain about arrays, Type of arrays and arrays methods. 03
(b) Explain about Encapsulation, Abstraction. 04
(c) State the design hints for class and inheritance. 07
Also discuss the working and meaning of the “static” modifier with
suitable examples.
OR
(c) Explain in detail how inheritance and polymorphism are supported in 07
java with necessary examples.
Q.3 (a) Explain about different types of string methods. 03
(b) Write short notes on access specifiers and modifiers in java. 04
(c) What is an Exception? Explain the exception hierarchy. Explain how 07
to throw, catch and handle Exceptions.
OR
Q.3 (a) Explain about Final class, Fields, Methods. 03
(b) What is a Package? What are the benefits of using packages? Write 04
down the steps in creating a package and using it in a java program
with an example.
(c) Explain the concept of inner classes and explain the types of inner 07
classes with an example program.
Q.4 (a) What is Dynamic binding? Show with an example how dynamic 03
binding works.
(b) Write short notes about I/O stream classes. 04
(c) Explain the thread state, thread properties and thread synchronization. 07
OR
Q.4 (a) Explain the concept of finalization. 03
(b) What is reflection and how does it help to manipulate java code. 04
(c) Write a java program to implement the multiple inheritance concepts 07
for calculating area of circle and square.
Q.5 (a) Explain about callback 03
(b) Explain the interface with an example program. 04
(c) What is Generic programming and why is it needed? Explain with 07
example. List the limitations and restrictions of generic programming
1
OR
Q.5 (a) Explain about Proxy class, Interface and Methods. 03
(b) Explain about adapter classes and mouse events with an example. 04
(c) With a neat diagram explain the Model view controller design pattern 07
and list out the advantages and disadvantages of using it in designing
an application.

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

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–IV (NEW) EXAMINATION – SUMMER 2022
Subject Code:3140705 Date:08-07-2022
Subject Name:Object Oriented Programming -I
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.
4. Simple and non-programmable scientific calculators are allowed.
Marks
Q.1 (a) List out features of Java. Explain any two features. 3
(b) Write a single program which demonstrates the usage of following 4
keywords:
i) import, ii) new, iii) this, iv) break, v) continue
Show how to compile and run the program in java.
(c) Demonstrate use of try-catch construct in case of hierarchical 7
Exception Handling. (i.e handling various exception belongs to the
exception hierarchy)

Q.2 (a) Explain following Java keywords using appropriate examples: 3


i) static, ii) final, iii) super
(b) Consider class A as the parent of class B. Explain among the 4
following which statement will show the compilation error.
i) A a = new A();
ii) A a = new B();
iii) B b = new A();
iv) B b = new B();
(c) Write a java program to take infix expressions and convert it into 7
prefix expressions.
OR
(c) Write a java program that evaluates a math expression given in string 7
form from command line arguments.

Q.3 (a) Defines types of inheritance. 3


(b) Explain the following constructors using appropriate example: 4
i) Default constructor and Parameterised constructor
ii) Shallow copy and Deep copy constructor
(c) Explain file io using byte stream with appropriate example. 7
hint: use FileInputStream, FileOutputStream
OR
Q.3 (a) Define types of polymorphism 3
(b) Explain the following: 4
i) Arguments and Parameters of a function
ii) Pass by Value and Pass by reference
1
(c) Explain file io using character stream with appropriate example. 7
hint: use FileReader, FileWriter

Q.4 (a) Define Encapsulation and access specifier 3


(b) Explain multithreading using Thread class 4
(c) Write a short note on Java Collections. 7
OR
Q.4 (a) Differentiate between Abstract class and Interfaces 3
(b) Explain multithreading using Runnable interface 4
(c) Write a program to add input elements in ArrayList collection class, 7
then sort the inserted elements in descending order and display the
sorted output.
hint: use Collections.reverseOrder()

Q.5 (a) Explain following Java keywords using appropriate examples: 3


i) throw, ii) throws, iii) finally
(b) In multi-threading using Thread class, explain with an example how 4
a start() method call invokes the run method of the class extending
Thread class.
(c) Write a short note on JAVAFX controls. 7
OR
Q.5 (a) Explain thread life cycle 3
(b) In multi-threads using the Runnable interface, explain with an 4
example how a start() method calls the run() method of a class
implementing a runnable interface.
(c) Develop a GUI based application using JAVAFX controls. 7

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

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE- SEMESTER–IV (NEW) EXAMINATION – WINTER 2020
Subject Code:3140705 Date:24/02/2021
Subject Name:Object Oriented Programming -I
Time:02:30 PM TO 04:30 PM Total Marks:56
Instructions:
1. Attempt any FOUR questions out of EIGHT questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.

Q.1 (a) What is the difference between oop and procedural oriented language? 03
(b) Explain type-conversion in java. 04
(c) Explain class and object with respect to java. 07

Q.2 (a) Difference between Nested if and multi-way if statements. 03


(b) What is constructor overloading? 04
(c) What are the data-types and operators available in Java? 07

Q.3 (a) Explain access modifiers with Example. 03


(b) Explain following keywords 04
1) Static 2) Super
(c) Differentiate between final, finally and finalize. What will happen if we make 07
class and method as final?

Q.4 (a) Explain abstract class with example. 03


(b) Explain Primitive data type and wrapper class data types. 04
(c) Write a program to rise and handle divide by zero exception. 07

Q.5 (a) Explain mouse and key event handler in JavaFX. 03


(b) Explain following controls 04
1) text-Area 2) scrollbar 3) checkbox 4) combo-box
(c) Write a method for computing xy doing repetitive multiplication. X and y are 07
of type integer and are to be given as command line arguments. Raise and
handle exception(s) for invalid values of x and y.

Q.6 (a) Explain following classes in JavaFX. 03


1) Color class 2) font class 3) Image and image view class
(b) What is Exception? Demonstrate how you can handle different types of 04
exception separately.
(c) List and explain available type of constructors in java with example. 07

Q.7 (a) Differentiate Text I/O and Binary I/O. 03


(b) Explain usage of class FileInputStream and FileOutputStream by giving an 04
example.
(c) Explain Comparable and Cloneable interface. 07

Q.8 (a) What is Collection? Explain list, stack, queue classes. 03


(b) How to access object via reference variable? Explain with example. 04
(c) What do you understand by thread? Describe the complete life cycle of 07
thread.

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

1
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–IV (NEW) EXAMINATION – WINTER 2021
Subject Code:3140705 Date:05/01/2022
Subject Name:Object Oriented Programming -I
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.
4. Simple and non-programmable scientific calculators are allowed.

MARKS
Q.1 (a) What are syntax errors (compile errors), runtime errors, and logic 03
errors?
(b) What is Type Casting? Explain widening and narrowing type 04
casting.
(c) Explain Data Types in detail with example. 07

Q.2 (a) What is an interface? Explain with example. 03


(b) Explain “Passing argument by values” with example. 04
(c) Explain File class with its methods. 07
OR
(c) What is polymorphism? Explain dynamic binding with example. 07
Q.3 (a) Explain abstract class with example. 03
(b) Explain Method Overloading and Overriding. 04
(c) Write a program that counts the number of words in a text file. 07
The file name is passed as a command line argument. The words
in the file are separated by white space characters.
OR
Q.3 (a) Differentiate String class and StringBuffer class. 03
(b) Explain following keywords 04
(1) super (2) this
(c) Write a program that illustrates interface inheritance. Interface P 07
is extended by P1 and P2. Interface P12 inherits from both P1 and
P2. Each interface declares one constant and one method. class Q
implements P12. Instantiate Q and invoke each of its methods.
Each method displays one of the constants.
Q.4 (a) Explain visibility modifiers. 03
(b) Explain following controls 04
(1) Checkbox (2) Radio Button (3) Textfield (4) Label
(c) What is an Exception? Explain try, catch and finally with 07
example.
OR
Q.4 (a) What is the keyword “throw” used for? What is the keyword 03
“throws” used for?
(b) What is constructor? Explain constructor overloading. 04
(c) Explain different layout panes used in JavaFX. 07
Q.5 (a) Differentiate Text I/O and Binary I/O 03
(b) Explain Inner class with example. 04
(c) What is thread? Describe the complete life cycle of thread. 07
OR

1
Q.5 (a) Compare List and Set. 03
(b) Explain static variable and static method with example. 04
(c) Explain Thread Synchronization with example. 07

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

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–IV(NEW) EXAMINATION – WINTER 2022
Subject Code:3140705 Date:20-12-2022
Subject Name:Object Oriented Programming -I
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.
4. Simple and non-programmable scientific calculators are allowed.
MARKS
Q.1 (a) Discuss significance of byte code. 03
(b) Explain Java garbage collection mechanism. 04
(c) List OOP characteristics and describe inheritance with examples. 07

Q.2 (a) Explain constructor with the help of an example. 03


(b) List out different methods available for String class in java and explain 04
any two with proper example.
(c) Explain all access modifiers and their visibility as class members. 07
OR
(c) Compare String with StringBuffer. Also, write a program to count the 07
occurrence of a character in a string.

Q.3 (a) What is the final class? Why they are used? 03
(b) Write exception handling mechanisms in JAVA. 04
(c) Explain Overloading and Overriding with example. 07
OR
Q.3 (a) How can you create packages in Java? 03
(b) What is Inheritance? List out the different forms of Inheritance and 04
explain any one with example.
(c) Explain the words super, static, final and this with the help of an 07
example.

Q.4 (a) List out various layout panes in JavaFX. 03


(b) Explain the architecture of JavaFX. 04
(c) Discuss BufferedInputStream and BufferedOutputStream classes with 07
an example.
OR
Q.4 (a) List out JavaFX UI controls and explain any one in detail. 03
(b) Demonstrate animation effect in JavaFX. 04
(c) Create a class called Student. Write a student manager program to 07
manipulate the student information from files by using FileInputStream
and FileOutputStream.

Q.5 (a) What is Java Collection? 03


(b) List out methods of Iterator and explain it. 04
(c) Explain Set and Map in Java with example. 07
OR
Q.5 (a) What is Vector class? 03
(b) Describe with diagram the life cycle of Thread. 04
(c) Explain synchronization in Thread with suitable example. 07
***********
1

You might also like