1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alexdok [17]
3 years ago
9

If the object instance is created in a user program, then the object instance can access both the public and private members of

the class using DOT notation (such as Rectangle r; r.area=10). True or False
Computers and Technology
1 answer:
rewona [7]3 years ago
5 0

Answer:

False

Explanation:

The private member of a class is not accessible by using the Dot notation ,however the private member are those which are not accessible inside the class they are accessible outside the class  .The public member are accessible inside the class so they are accessible by using the dot operator .

<u>Following are the example is given below in C++ Language </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {     return 3.14*r*r;  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 3.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Output:

compile time error is generated

<u>The correct program to access the private member of class is given below </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {    

r1=r;

double t2=3.14*r2*r2;

return(t2); // return the value  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 1.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Therefore the given statement is False

You might be interested in
The sheep in the image below is an example of which of the following?
n200080 [17]

Answer:

balanced space.

Explanation:

This is a edu guess.

5 0
2 years ago
Write a program for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program
Margaret [11]

Answer:

from random import randint

winner  = False

number = str(randint(10000, 99999))

while (not winner):

   correct = 0

   total = 0

   guess = input()

   

   if(number==guess):

       winner = True

   else:

       for i in range(5):

           if(number[i] == guess[i]):

               correct+=1

               total+=int(number[i])

       

       print('Correct: '+ str(correct))

       print('Total: '+ str(total))

print('Winner')

Explanation:

I´m gonna show a solution in python 3

Step 1 import library for generate random number

from random import randint

Step 2 create necesary variables to get the number and if the player is winner or not

winner  = False

number = str(randint(10000, 99999))

Step 3 loop while the player is not the winner

while (not winner):

Step 4 get the player guess number

guess = input()

Step 5 validate if the player win

if(number==guess):

       winner = True

Step 6 if the player is not winner review what numbers are  in the correct position

for i in range(5):

           if(number[i] == guess[i]):

               correct+=1

               total+=int(number[i])

Step 7 print the hint

print('Correct: '+ str(correct))

print('Total: '+ str(total))

6 0
3 years ago
An animal shelter recently held an adoption event and found homes for 48 of their shelter animals. If they found home for 80% of
vredina [299]

Answer:

9.6

Explanation:

4 0
3 years ago
Read 2 more answers
In this exercise you will debug the code which has been provided in the starter file. The code is intended to take two strings,
vampirchik [111]

Answer:

Here is the corrected program:

import java.util.Scanner; //to accept input from user

public class 02_14_Activity_one { //class name

    public static void main(String[] args) { //start of main method

    Scanner scan = new Scanner(System.in); //creates Scanner class object

  System.out.println("Enter first string"); //prompts user to enter first string

          String s1 = scan.nextLine(); //reads input string from user

  System.out.println("Enter second string"); //prompts user to enter second string

          String s2 = scan.nextLine(); //reads second input string from user

    System.out.println("Enter number of letters from each word"); //enter n

          int n = scan.nextInt(); //reads value of integer n from user

          System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));

         } } //uses substring method to print a string made up of the first n letters of s1 and the last n letters of s2.

Explanation:

The errors were:

1.

Scanner scan = Scanner(System.in);

Here new keyword is missing to create object scan of Scanner class.

Corrected statement:

 Scanner scan = new Scanner(System.in);

2.

String s1 = nextLine();  

Here object scan is missing to call nextLine() method of class Scanner

Corrected statement:

String s1 = scan.nextLine();

3.

String s2 = Scanner.nextLine();

Here class is used instead of its object scan to access the method nextLine

Corrected statement:

String s2 = scan.nextLine();

4.

String n = scan.nextLine();

Here n is of type String but n is a whole number so it should be of type int. Also the method nextInt will be used to scan and accept an integer value

Corrected statement:

int n = scan.nextInt();

5.

System.out.println(s1.substring(1,n-1) + s2.substring(s1.length()-n));

This statement is also not correct

Corrected statement:

System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));

This works as follows:

s1.substring(0,n) uses substring method to return a new string that is a substring of this s1. The substring begins at the 0th index of s1 and extends to the character at index n.

s2.substring(s2.length() - n ) uses substring method to return a new string that is a substring of this s2. The substring then uses length() method to get the length of s2 and subtracts integer n from it and thus returns the last n characters of s2.

The screenshot of program along with its output is attached.

7 0
3 years ago
Explain the rationale of using hexadecimal notation by computer programmers
zhuklara [117]

Answer:

Hexadecimal numerals are widely used by computer system designers and programmers, as they provide a human-friendly representation of binary-coded values. Each hexadecimal digit represents four binary digits, also known as a nibble, which is half a byte.

Explanation:

4 0
3 years ago
Other questions:
  • 10 10 105 Each process is assigned a numerical priority, with a higher number indicating a higher relative priority. In addition
    8·1 answer
  • The variable grade can have any real number value from 0 to 100. Ask the user to enter a grade in numerical form. Write an if-el
    9·1 answer
  • The data structure used for file directory is called
    7·1 answer
  • Which of the following statements opens the file info.txt for both input and output? a) dataFile.open("info.txt", ios::in &amp;&
    11·2 answers
  • Guys Do you know about e-waste recycling well ?
    9·2 answers
  • Customizable diagrams, including List, Process, and Cycle diagrams, are built into Word and can be found in
    7·1 answer
  • Software that displays advertising material when online.
    12·2 answers
  • Consider the following code: def tryIt(b): for i in range(len(b)): b[i] = b[i] + 100 #***********MAIN************ x = [] x = [56
    8·1 answer
  • Use the commands you've learned so far to draw a
    12·1 answer
  • A typeface, plus any special attributes applied to the text is called ________.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!