0% found this document useful (0 votes)
3 views5 pages

OOP Assignment 1: Java Concepts

The document contains an assignment for an Object-Oriented Programming course, featuring questions on Java concepts such as returning objects from methods, differences between one-dimensional and two-dimensional arrays, method overriding versus overloading, and access protection levels within classes. Each question is designed to assess understanding of fundamental Java programming principles. The assignment includes specific marks allocated to each question.

Uploaded by

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

OOP Assignment 1: Java Concepts

The document contains an assignment for an Object-Oriented Programming course, featuring questions on Java concepts such as returning objects from methods, differences between one-dimensional and two-dimensional arrays, method overriding versus overloading, and access protection levels within classes. Each question is designed to assess understanding of fundamental Java programming principles. The assignment includes specific marks allocated to each question.

Uploaded by

ksa.aa1502
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Name:

University number:
Object-Oriented Programming
Assignment #1

Q1: Explain the concept of returning an object from a method in Java. Illustrate your
explanation by describing what happens in the following code snippet: (2 Marks)

public Fraction1 simplify() {


int num = getNumerator();
int denom = getDenominator();
int gcd = gcd(num, denom);
Fraction1 simp = new Fraction1(num / gcd, denom /
gcd);
return simp;
}
Name:
University number:

Q2: Explain the difference between one-dimensional and two-dimensional arrays in Java.
How would you access an element in a two-dimensional array, and what are some practical
applications of such arrays? (1.5 Marks)
Name:
University number:

Q3: Explain the difference between method overriding and method overloading in Java.
How does method overriding support runtime polymorphism? Provide an example to
illustrate your answer. (1.5 Marks)
Name:
University number:

Q5: What are the different levels of access protection available for members within a class
in Java? How do packages play a role in access control? (2 Marks)
Name:
University number:

You might also like