Gujarat Technological UniversitySummer 2024 examination

GTU 3140705 Object Oriented Programming -I (Java) Summer 2024 Question Paper & PDF

B.E. · Computer Engineering · Semester 4 · Subject code 3140705
Download official PDFView PDF here
Share with your class
Total
70 marks
To pass
23 marks (33%)
Duration
2.5 Hours 10:30 AM – 1:00 PM
Questions
5 with internal choice
No solutions on this paper yetNeed them for your exam? Ask once. Papers that students ask for are solved first, and we aim to add them within 24 hours.

8 of 25 questions on this paper were also asked in other years. 1 more is a type of question GTU sets again with new data. Each is marked below with the years it appeared.See all 25 repeated 3140705 questions, most asked first

Q.1

14 Marks
(a)
3 marks

Answer in one word:(one mark for each)

IWhich integral type in Java has the exact range from - 2147483648 (-2³¹) to 2147483647 (2³¹-1).
IIThe software for developing and running Java programs.
IIIIt is similar to machine instructions but is architecture neutral and can run on any platform that has a Java Virtual Machine (JVM).
(b)
4 marks

Write a program that reads an integer and adds all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14. Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digit. For instance, 932 % 10 = 2 and 932 / 10 = 93.

(c)
7 marks

Analyze following code pieces (assume they are properly enclosed in class and main function) and write the output/error (No justification is required): (one mark for each)

Iint num = 5; int x = 1; for (int i = 1; i <= num; i++) { x *= i; } System.out.println("x is " +
x); II. int[] nums = {1, 5, 3, 9, 7}; int m= 1; int s= 0; for (int i = 0; i < nums.length; i++) { if (nums[i] > m) { s = m; m = nums[i]; } else if (nums[i] > s && nums[i] != m) { s = nums[i]; } } System.out.println("s is: " + s); 07 P A G III. int i=1,j=0,k=0; if (i > k) { if (j > k) System.out.println("i and j are greater than k"); } else System.out.println("i is less than or equal to k"); IV. int x = 3, y = 3; switch (x +
3){ case 6: y = 1; default: y += 1; } System.out.println("y is " + y); V. class HelloWorld { public static void main(String[] args) { int[] numbers = new int[1]; numbers[0]=0; m(numbers); System.out.println("numbers[0] is" + numbers[0]); } public static void m(int[] y) { y[0] = 3; } } VI. StringBuffer s1 = new StringBuffer("Complete"); s1.setCharAt(1,'i'); s1.setCharAt(7,'d'); System.out.println(s1); VII. int Integer = 24; char String ='I'; System.out.print(Integer); System.out.print(String);

Q.2

14 Marks
(a)
3 marksAsked in 2 of 7 papers

Describe the relationship between an object and its defining class.

Also asked in Winter 2023 Q2a

(b)
4 marks
Write java statements for following class:

public class Counter { int c; }

iDeclare a parameterized constructor to initialize variable c.
iiDeclare instance method to increment c and return updated value of c.
(c)
7 marks
Justify following:
iIn general, constructors should be public.
iiWhy main is declared as static.
iiiWhy we do not declare destructors in java.
ivThere is no pointer in java.
(c)
7 marks
Differentiate between following:
ithis keyword vs super keyword
iiabstract class vs interface

Q.3

14 Marks
(a)
3 marks

Give definition of method overloading. P A G

(b)
4 marks
iAnalyze following code pieces and write the

output/error and briefly justify output: public class Test { public static void main(String[] args) { new Person().printPerson(); new Student().printPerson(); } } class Student extends Person { @Override public String getInfo() { return "Student"; } } class Person { public String getInfo() { return "Person"; } public void printPerson() { System.out.println(getInfo()); } }

iiGiven the following source code, which comment line can be uncommented without introducing errors? abstract class MyClass { abstract void f(); final void g() {} //final void h() {} // comment (1) } final class MyOtherClass extends MyClass { public static void main(String[] args) { MyClass mc = new MyOtherClass(); } void f() {} void h() {} //void g() {} // comment (2) }
i)Analyze following code pieces and write the output/error and briefly justify output: public class Test { public static void main(String[] args) { new Person().printPerson(); new Student().printPerson(); } } class Student extends Person { @Override public String getInfo() { return "Student"; } } class Person { public String getInfo() { return "Person"; } public void printPerson() { System.out.println(getInfo()); } } ii. Given the following source code, which comment line can be uncommented without introducing errors? abstract class MyClass { abstract void f(); final void g() {} //final void h() {} // comment
1)} final class MyOtherClass extends MyClass { public static void main(String[] args) { MyClass mc = new MyOtherClass(); } void f() {} void h() {} //void g() {} // comment
2)}
(c)
7 marksAsked in 3 of 7 papers

Discuss public, private, protected and default access modifiers with examples.

Also asked in Summer 2025 Q2b, Winter 2024 Q2b

(a)
3 marksAsked in 2 of 7 papers

What is the final keyword? Give different uses of the final keyword.

Also asked in Winter 2024 Q2a

(b)
4 marks

Declare an interface called Function that has a method named evaluate that takes an int parameter and returns an

intvalue.
Createa class called Half that implements the Function
interface.The implementation of the method evaluate()
shouldreturn the value obtained by dividing
theint argument by 2.
(c)
7 marksAsked in 2 of 7 papers

What is an Exception? Explain Exception handling in JAVA with the help of example. 07 P A G

Also asked in Winter 2025 Q2c

Q.4

14 Marks
(a)
3 marksAsked in 5 of 7 papers

How do keyword throw differ from throws in Exception handling?

Also asked in Summer 2026 Q4b OR, Summer 2025 Q4a OR, Winter 2024 Q4a OR, Summer 2023 Q3b

(b)
4 marks

Differentiate between a byte oriented and a character- oriented stream.

(c)
7 marks

Explain binary I/O classes. Demonstrate java file I/O with any I/O class to read a text file.

(a)
3 marksAsked in 2 of 7 papers
Compare JavaFX with Swing and AWT.

Also asked in Winter 2023 Q5a OR

(b)
4 marks
iList any four UI controls in JavaFX.
iiList any two Panes for Containing and Organizing Nodes
(c)
7 marksSame type asked in 4 of 7 papers

Write a program to demonstrate GUI application development using JavaFX.

Also asked in Winter 2025 Q5c, Winter 2024 Q5c OR, Winter 2023 Q5c OR

Q.5

14 Marks
(a)
3 marks

What are the differences between ArrayList and LinkedList? Which list should you use to insert and delete elements at the beginning of a list?

(b)
4 marks

What is Java Collection Framework? List four collection classes?

(c)
7 marks

Give the name of class or interface that provides following facility (Do not elaborate)(one mark for each)

iDynamic array to store the duplicate element of different data types. It maintains the insertion order.
iiImplements the last-in-first-out data structure.
iiiImplements the first-in-first-out data structure.
ivImplements the first-in-first-out data structure and it holds the elements or objects which are to be processed by their priorities.
vIt represents the unordered set of elements which doesn't allow us to store the duplicate items.
viIt is a red-black tree-based implementation. It provides an efficient means of storing key-value pairs in sorted order.
viiIt allows us to store key and value pair, where keys should be unique.
(a)
3 marksAsked in 5 of 7 papers
Explain thread life cycle.

Also asked in Summer 2026 Q5c, Winter 2025 Q4b, Summer 2025 Q5b, Summer 2023 Q3a OR

(b)
4 marksAsked in 3 of 7 papers

What is the package? Explain steps to create a package with example.

Also asked in Summer 2025 Q3b OR, Winter 2024 Q4c

(c)
7 marks

Declare a class called Employee having employee_Id and employee_Name as members. Extend class Employee to have a subclass called SalariedEmployee having designation and monthly_salary as members. Define following:

  • Required constructors
  • Methods to insert, update and display all details of employees.
  • Method main for creating an array for storing these details given as command line arguments and showing usage of above methods.

More Object Oriented Programming -I papers

Questions repeat across sessions. Working through two or three papers shows you which topics GTU asks most.

Preparing with friends?

Send this paper to your class group. Every question has its own link.

About this paper

Official Gujarat Technological University (GTU) examination paper for Object Oriented Programming -I (Java) (Summer 2024, B.E. · Computer Engineering, Sem 4). Features complete 70-mark regular & remedial examination pattern, official marking distribution across all 5 questions, and direct 1-click official PDF download.

Transcribed for student exam preparation from Gujarat Technological University official examination archives. Questions, syllabus guidelines, and curriculum marking schemes remain the intellectual property of Gujarat Technological University.

ViewDownload PDF