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

Object Oriented Programming - ASSIGNMENT (2)

The document outlines the curriculum for IT 214 - Object Oriented Programming, focusing on methods in Java. It covers basic concepts such as predefined and user-defined methods, as well as advanced topics like pass-by-reference parameters and the use of arrays as method parameters and return values. Key examples include the use of Math.sqrt() and constructing methods that manipulate arrays.

Uploaded by

ubaldedaldine
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)
8 views5 pages

Object Oriented Programming - ASSIGNMENT (2)

The document outlines the curriculum for IT 214 - Object Oriented Programming, focusing on methods in Java. It covers basic concepts such as predefined and user-defined methods, as well as advanced topics like pass-by-reference parameters and the use of arrays as method parameters and return values. Key examples include the use of Math.sqrt() and constructing methods that manipulate arrays.

Uploaded by

ubaldedaldine
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/ 5

1st Semester, SY 2024-2025

IT 214 – Object Oriented Programming

Topic : Unit V. Basic Concept of Methods

a. Predefined Methods

b. User-defined Methods

• Method declaration

• Method Call

• Void methods

Unit VI. Advanced Concepts of Methods with Parameters

a. Pass-by-reference parameter
b. Use of arrays as parameter of returned values
c. User-defined methods

• Methods and return values

Unit V. Basic Concept of Methods

a. Predefined methods are the ones that the Java class libraries already define.
This means that they can be called and used anywhere in our program without
defining them. There are numerous predefined methods, such as length(),
sqrt(), max(), and print(), and each of them is no defined inside their respective
classes.
• In this program we use the predefined method. For example, if you’re using
java, you can use Math.sqrt() is a method from math class in java. It’s designed
to calculate the square root of a number.

b. Construct and use a user defined method using passby-value parameter.


• Pass-by-value it means : Java uses pass-by-value for method parameters. This
means a copy of the argument’s value is passed to the method, not the original variable
itself.

• In this program variables declared within a method (like value in changeValue )


have local scope. They are not accessible outside that method.

Unit VI. Advanced Concepts of Methods with Parameters.

a. Demonstrate passing reference parameter


• Pass-by-reference when a method is called, a reference (memory address) to
the original variable is passed to the method.
• A modifications to the properties of an object or elements of an array inside the
method will reflect on the original object/array. Demonstrating pass- by-
reference.
b. Explain the use of arrays as returned value:
• Methods can return arrays, it means that you can write a method in java that
will return an array full of values.
• Arrays can be passed to method as arguments and methods can return an array.
Arrays are Passed-By-Reference. That means, When an array is passed to a
method, reference of an array object is passed not the copy of the object.

c. Construct and use a user-defined method using arrays as a parameter or as a


return value:
• Create a method that either accepts an array as a parameter or returns an array
Example of a method that accepts an array as a parameter:
Example of a method that returns an array:

• Defines a method to calculate the square of a number.


• Calls this method with the number 10.
• Stores the returned value in a variable.
• Prints the squared value to the console.

Reference:

• GeeksforGeeks : https://www.geeksforgeeks.org/methods-in-java/

• W3Schools : https://www.w3schools.com/java/java_methods.asp

• Simplilearn.com : https://www.simplilearn.com/tutorials/java-tutorial/methods-in-
java

You might also like