Write a method named showChar. The method should accept two arguments:

Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The integer argument is a character position within the String, with the first character being at position 0. When the method executes, it should display the character at that character position. The method does not return anything. Here is an example of a call to the method:____________

2 months ago

Solution 1

Guest Guest #2390735
2 months ago

Complete Question:

Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The integer argument is a character position within the String, with the first character being at position 0. When the method executes, it should display the character at that character position. The method does not return anything.

Here is an example of a call to the method:

showChar("New York", 2);

In this call, the method will display the character w because it is in position

2. Demonstrate the method in a complete program.

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

   Scanner in = new Scanner (System.in);

       System.out.println("Enter a word");

       String word = in.next();

       System.out.println("Enter an index position, a positive number please");

       int n = in.nextInt();

       showChar(word,n);

   }

   public static void showChar(String word, int n){

       System.out.println(word.charAt(n));

   }

}

Explanation:

  1. In creating the method showChar, we declared it to be void (since it will return no value) and to receive two parameters a string and an int
  2. Using the string method charAt in java, the method prints the character at index n
  3. We created a main method where a user is prompted to enter values for the string and the index
  4. The method showChar is then called and passed the values

📚 Related Questions

Question
While writing a program to regulate the speed of a self-driving car, you find that your software sometimes miscalculates the ideal car speed for city streets to be over 1500 MPH (nearly twice the speed of sound), when it should be approximately 30 MPH. Which of the following strategies would be most efficient to employ in debugging your program? a. At the very end of the speed calculations, add an additional line of code that divides the calculated speed by 50 so that the program never produces such high speeds b. After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced. c. Starting at the end of your program and working backwards, systematically delete each line of code that relates to calculating and re-run the program after each deletion to identify where in the program the error is being introduced d. Delete all of the code relating to speed calculations and rewrite it again
Solution 1

Answer:

b. After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced.

Explanation:

Logging statements are an effective debugging technique. It is a good way of finding the location of faulty logic in a program.

One can trace the root problem through logging intermediary outputs.

We can find out from where the program is producing unexpected or unintended calculations, when their's a weird output logged.

Question
________ is a model of computing in computer processing, storage, software, and other services which are provided as a shared pool of virtualized resources over the Internet.
Solution 1

Answer:

"Cloud computing" is the correct answer .

Explanation:

Cloud computing is defined as it provided the resources of the system like data storage etc on the demanding purpose. In cloud computing, it provided the resources without knowing the management. Social media is one of the examples of cloud computing.

  • Cloud computing is a model in the computer system that stores the bulk data provided the services to the user on demands.
  • Cloud computing acts as a shared pool of virtual resources on the internet.
Question
Which of the following statements is false: A. Mobile devices must be concerned with power consumption. B. Mobile devices can provide features that are unavailable on desktop or laptop computers. C. The difference in storage capacity between a mobile device and a laptop is shrinking. D. Mobile devices usually have fewer processing cores than a standard desktop computer.
Solution 1

Answer:

Option C is false.

Explanation:

The following option is false because the storage capacity of the mobile and the laptops is increasing day-by-day with new models, good features, best storage capacity, and with good battery backup. So, it is not true that the storage capacity of the following devices is shrinking.

  • Option A is true about the statement because power consumption will involve mobile devices.
  • Option B is true about the statement because mostly features in the mobile devices are unavailable on mobile devices such as portability that is we can use mobiles anywhere and any time and they have one of the best features of calling and messaging anywhere at any time.
  • Option C is true about the statement because computer systems have higher levels of software that required good processors for working.
Question
What essential part of the operating system communicates with the BIOS, device drivers, resource managers, and APIs to coordinate operating system functions?
Solution 1

Answer:

The answer for the part of the operating system communicates with the BIOS, device drivers, resource managers, and APIs to coordinate operating system functions is the Kernel.

Explanation:

The Kernel is the part of the operating system that is most visible to users.

It provides a reference point for activities in the operating system and coordinates operating system functions.

The kernel communicates with the BIOS, device drivers, and the API and handles the hardware, timing schedule, peripherals, memory, disks and user access.

Question
A dictionary password attack is a type of attack in which one person, program, or computer disguises itself as another person, program, or computer to gain access to some resource. A. True B. False
Solution 1

Answer:

A

Explanation:

Question
What term is used for a computer that belongs to a group of networked computers, all working mindlessly to serve the person who installed the program on the computers?
Solution 1

Answer:

Zombie.

Explanation:

A zombie is a computer that is connected to the internet or a network but has been infiltrated by a Trojan horse, computer virus or hacker. This activity is not noticed by the owner or user of the computer.

These zombies usually launch DoS (Denial of Service) attacks and mostly spread email spam. They can be used also to get vital information about an organization or government agencies.

Up-to-date security measures must be installed and carefully considered to prevent these attacks.

Question
Which function of InfoSec management encompasses security personnel as well as aspects of the SETA program?
Solution 1

Answer:

People

Explanation:

Information security management provides a description of the controls needed by an organization in order to ensure that it is capable of protecting the integrity, availability, and confidentiality of assets from security vulnerability and threats. On the other hand, the SETA program is three phased and ensures that organizations address and implement training and techniques for information security. Hence the only function that encompasses security personnel as well as aspects of the SETA program is the People function.

Question
A runtime error occurs when Select one: a. the Java compiler can't be located b. bytecode can't be interpreted properly c. there's a syntax error in a Java statement d. the name of the .java file and the class don't match
Solution 1

Answer:

Option C is true.

Explanation:

The above statement is true because a runtime error occurred when the error in the syntax of any programming language such as Java, C, C++, Python, and many other programming languages. So, it is the genuine reason for the runtime error is that the syntax error.

  • Option A is not true about the statement because when the compiler of Java cannot be located, then it not generate the runtime error. The other error should be there.
  • Option B is not true about the statement because it is the responsibility of the JVM to convert bytecode into the machine language.
  • Option C is not true about the statement because when the name of the java file or the class name does not match then it occurs error but not the runtime error.
Question
Which of the following are examples of algorithms? (Select all that apply, if any do.) a. The mathematical formula for finding the area of a circle. b. A list of your favorite animals. c. A problem statement. d. Instructions for setting up a new DVD player. e. A series of steps that moves a "lighting bot" around to turns on lights.
Solution 1

Answer:

A. The mathematical formula for finding the area of a circle.

D. Instructions for setting up a new DVD player

E. A series of steps that moves a "lighting bot" around to turns on lights.

Explanation:

Algorithm is a systematic procedure (or process) that produces the answer to a question or the solution of a problem in a finite number of steps.

Option A is an algorithm. The mathematical formula for finding the area of a circle gives a solution to a problem. The problem is finding area of a circle and the formula gives the step by step procedure finding the area of a circle.

Option B is not an algorithm. Option B just provide a list of your favourite animals and it doesn't answer a question we know about.

Option C is not an algorithm. A problem statement is still a problem with no solution whereas algorithm provides solution

Option D is an algorithm. It provides the step by step procedures for setting up a new DVD player

Option E is an algorithm. It provides a series of steps that moves a lighting bot around to turns on lights, so it provides a solution.

Solution 2

Answer:

c, d and e.

Explanation:

An algorithm is a step by step procedure  

in solving a particular problem. An algorithm is finite - it has a beginning and an end.

With the options provided;

* option a is not an algorithm, though it describes the tool  to solving a problem, it does not specify the steps involved in solving the problem.

* option b is also not an algorithm because it only shows a list of favorite animals and  that is solving no problem.

* option c is also an algorithm. An algorithm solves a problem by providing steps to solving it.  A problem statement describes the problem, and the steps on how to solve the problem.

* option d is an algorithm. Setting up the new DVD player is the problem. Steps for setting it up are shown in the instructions. Therefore, since a problem will be solved by following those instructions, that option is an algorithm.

* option e is also an algorithm. Moving a lighting bot around to turn on the lights is the problem. How this is solved are shown in the series of steps. This makes option e and algorithm.

Question
Coding a record for subject storage involves a. all of these choices. b. verifying that the subject is in the master index. c. preparing a records index. d. underlining cross-reference subjects with a wavy line.
Solution 1

Answer:

The answer is "Option d".

Explanation:

In database, the basic information object often referred to as the configuration, structure or composite records. In this storing process the developer can describe new record type to emphasizes the wavy row cross-reference patterns and other options, that could be identified as follows were incorrect:

  • Option b is not useful to verify the subject, that's why it is wrong.
  • Option c doesn't help in preparing records, that's why it is incorrect.