Search Header Logo
Parameterised Constructors

Parameterised Constructors

Assessment

Presentation

Computers

10th Grade

Medium

Created by

Rajat Shenoi

Used 12+ times

FREE Resource

14 Slides • 4 Questions

1

Parameterised Constructors

User - defined methods

Slide image

2

A quick revision

  • Advantages of a method

  • Header (Prototype)

  • Signature

  • Access-specifier

  • Return type

  • Parameter list

  • Method Block

3

continuation...

  • A method is a block of code which only runs when it is called.

  • You can pass data, known as parameters, into a method.

  • Methods are used to perform certain actions, and they are also known as functions.

  • Why use methods? To reuse code: define the code once, and use it many times.

4

Parameterised Methods

long time since I started to say next class I will teach this and there has gone about 4 classes without teaching....


finally the time has come! :)

5

Parameters and Arguments

  • Information can be passed to methods as parameter. Parameters act as variables inside the method.

  • Parameters are specified after the method name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma.

  • The following example has a method that takes a String called fname as parameter. When the method is called, we pass along a first name, which is used inside the method to print the full name

  • Over to AWS...

6

Multiple Parameters

  • you can have as many parameters as you like :)

  • Note that when you are working with multiple parameters, the method call must have the same number of arguments as there are parameters, and the arguments must be passed in the same order.

  • over to AWS....

7

Return Values

The void keyword, used in the examples above, indicates that the method should not return a value. If you want the method to return a value, you can use a primitive data type (such as int, char, etc.) instead of void, and use the return keyword inside the method


over to AWS...

8

Purity of functions... (informal)

  • Function which returns a value is called a pure function

  • A function which may not return a value but changes the state of an object is known as impure function.

9

Some questions for you

ATB!


You will have only 10 seconds to answer each question.

Are you ready? Cause we are starting in...

10

Multiple Choice

Calling and invoking a function is same.

1

True

2

False

11

Multiple Choice

A method can use a single return statement.

1

True

2

False

12

Multiple Choice

A function cannot be defined without parameters.

1

True

2

False

13

Multiple Choice

A function body is enclosed within curly brackets.

1

True

2

False

14

Homework

  • Question 11 (Pg 313)

  • Question 12 (Pg 313)

  • Deadline: before next class.

15

When is the next class?

You tell me. We have 11 more classes to go.

16

What will we do in the next class?

  • Function Overloading

  • Need for Function Overloading

  • Defining Overloaded Functions

  • Written test (30 minutes, 20 marks)

17

More about the test

  • Questions will be sent on google classroom as an assignment.

  • Duration: 30 minutes

  • Exam will be written and NOT typed.

  • You will get additional 10 minutes to click a photo of the paper and send it.

  • Submissions after 40 minutes of releasing of question paper will lose 1 marks per minute.

  • Portions: Chapter 5 and 6

  • YOU MUST BE ON CAMERA DURING THE TEST.

18

How to submit?

You can either submit using google classroom via the method shown on the right (By choosing 'file')


Or submit the file using a link which will be easier if you are using mobile phone, because otherwise you may have to transfer to the laptop and then submit which may take time hence losing marks.


The link will be sent when the exam begins.

Slide image

Parameterised Constructors

User - defined methods

Slide image

Show answer

Auto Play

Slide 1 / 18

SLIDE