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
lina2011 [118]
4 years ago
13

(Java) I need help understanding what to code for these methods.

Computers and Technology
1 answer:
Nuetrik [128]4 years ago
7 0

Answer:

public Mysring(char[] Original)

{

        int size= Original.length();

       for(int i=0;i<=size;i++)

       {

           arr[i]=Original[i];

       }

}

Public Mystring(String Original)

{

  char[] arr=String.toCharArray();

}

Public Mystring(Mystring Original)

{

   Int len=Original.arr.length();

   for(int i=0;i<=len;i++)

   {

        arr[i]=Orginal.arr[i];

   }

}

public int length()

{

    Int len=arr.length();

   return len;

}

Public char charAt(int index)

{

     try

     {

      System.out.println(arr[index]);

     }

     catch(IndexOutOfBoundsException ex)

     {

          throw ex;

     }

}

   

}

Explanation:

1) The first one is the Parameterized constructor. It takes an array of character as input, and assigns it to the array of character which is a field in the given class MyString.

2) The second one is also the Parameterized constructor, and it takes a string as input, and converts it to an array of characters, and finally assigns it to the character type field of the class MyString.

3) The third one is the copy constructor, and takes a previous object of the class as input, and assigns its values to the new instance of the class.

4) The fourth function returns the length of the character field of the class MyString.

5) The fifth function returns the character in the character field at the given index. And if Index is more than the length of the arr field, it through the IndexOutOfBoundsException.

You might be interested in
What is the potential outcome for an author if she uses a word without realizing its connotation? she may write something that s
zubka84 [21]

A potential outcome for an author who uses a word without realizing its connotation is: A. she may write something that she does not mean.

<h3>What is connotation?</h3>

Connotation refers to the quality, feeling or an idea which a word brings to the mind of a reader or listener, as well as its literal, dictionary or primary meaning.

This ultimately implies that, a potential outcome for an author who uses a word without realizing its connotation is that he or she may write something that she does not mean or pass across an information she didn't intend to.

Read more on connotation here: brainly.com/question/20236939

#SPJ1

3 0
2 years ago
Which of the following is not a type of Internet Job Board? Options Resume Blaster Professional Association Target Applicants We
mr Goodwill [35]
The answer is : Weighted application blanks

Job board is a type of system in which the employers set up a list of requirements for the job hunter

Weighted Application blanks is used to to collect background information from the job applicants, which is not a part of job board
6 0
3 years ago
Input 10 integers and display the following:
LekaFEV [45]

Answer:

// code in C++

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int sum_even=0,sum_odd=0,eve_count=0,odd_count=0;

   int largest=INT_MIN;

   int smallest=INT_MAX;

   int n;

   cout<<"Enter 10 Integers:";

   // read 10 Integers

   for(int a=0;a<10;a++)

   {

       cin>>n;

       // find largest

       if(n>largest)

       largest=n;

       // find smallest

       if(n<smallest)

       smallest=n;

       // if input is even

       if(n%2==0)

       {  

           // sum of even

           sum_even+=n;

           // even count

           eve_count++;

       }

       else

       {

           // sum of odd    

          sum_odd+=n;

          // odd count

          odd_count++;

       }

   }

   

   // print sum of even

   cout<<"Sum of all even numbers is: "<<sum_even<<endl;

   // print sum of odd

   cout<<"Sum of all odd numbers is: "<<sum_odd<<endl;

   // print largest

   cout<<"largest Integer is: "<<largest<<endl;

   // print smallest

   cout<<"smallest Integer is: "<<smallest<<endl;

   // print even count

   cout<<"count of even number is: "<<eve_count<<endl;

   // print odd cout

   cout<<"count of odd number is: "<<odd_count<<endl;

return 0;

}

Explanation:

Read an integer from user.If the input is greater that largest then update the  largest.If the input is smaller than smallest then update the smallest.Then check  if input is even then add it to sum_even and increment the eve_count.If the input is odd then add it to sum_odd and increment the odd_count.Repeat this for 10 inputs. Then print sum of all even inputs, sum of all odd inputs, largest among all, smallest among all, count of even inputs and count of odd inputs.

Output:

Enter 10 Integers:1 3 4  2 10 11 12 44 5 20                                                                                

Sum of all even numbers is: 92                                                                                            

Sum of all odd numbers is: 20                                                                                              

largest Integer is: 44                                                                                                    

smallest Integer is: 1                                                                                                    

count of even number is: 6                                                                                                

count of odd number is: 4

3 0
4 years ago
Two or more computers connected together is referred to as a(n)
son4ous [18]
Two or more computers connected together is referred to as a network.
So the answer is <span>B. network.</span>
8 0
3 years ago
Which topology requires a multipoint connection?
Nina [5.8K]
It's C) Bus Bus topology requires a multipoint connection
5 0
4 years ago
Other questions:
  • Free points! your welcome
    9·2 answers
  • 4. A friend knows you are taking a technology class in college and asks you how a hard drive works. In your own words, describe
    6·1 answer
  • All of the following are potential benefits of blogging except
    10·1 answer
  • Email, instant messaging and most web traffic go across the internet in the clear; that is, anyone who can capture that informat
    15·2 answers
  • A large corporation uses:<br>LAN<br>WAN<br>Wireless network<br>Ethernet connection​
    13·2 answers
  • Which statement assigns the value 98 to the variable myScore in Python?
    14·2 answers
  • A bear is an animal and a zoo contains many animals, including bears. Three classes Animal, Bear, and Zoo are declared to repres
    12·1 answer
  • 52. An assignment statement will:
    11·2 answers
  • 5. Played electronically by manipulating images on a television screen produced by a
    15·1 answer
  • How to add up multiple user inputs for example: If i ask the user How many numbers do you want to add? they say 5 then i out put
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!