Computer Science, asked by srividyaavuthu2020, 4 months ago

class brush
{
private:
integer size,
rcode
function getdata() { ... }// Statement 1
public:
integer name // Statement 2
function putdata() { ... }
}
function main
{
brush b1,b2
print b1.name // Statement 3
b2.getdata() //Statement 4
}​

Answers

Answered by ganeganeshmothukuri
16

Answer:

statement 4 is the correct answer

Answered by mindfulmaisel
11

statement 4 will lead to an error

Explanation:

class brush

{

private:

integer size,

function getdata() { ... }// Statement 1

public:

integer name // Statement 2

function putdata() { ... }

}

function main

{

brush b1,b2

print b1.name // Statement 3

b2.getdata() //Statement 4

}​

Running program, statement 4 will lead to error.

Reason:

  • statement 4 = b2.getdata()
  • which means the b2 object is trying to access a private method that is not possible

hence, statement 4 will lead to an error.

Similar questions