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
strojnjashka [21]
2 years ago
12

You have been handed a mysterious piece of data by an unknown person. Judging by his shifty eyes and maniacal laughter you don't

think he can be trusted. Complete the below method to tell you the type for this unknown data. The example already implemented can be adapted for other wrapper classes as well. Complete the method to analyze String, Character, and Double. Examples: whatAmI(1) -> "Integer" 1 public String whatAmI(E e) { 3 //.getClass() returns the runtime class of an object //.equals() determines whether two objects are equivalent //by calling a new static instance of a wrapper object we can analyze //it's class type and compare it to the variable passed in if(e.getClass().equals(new Integer(1).getClass()) { return "Integer"; }else{ return "Who knows!"; Given a word, use a stack to reverse the word and return a new string with the original word in reverse order. You cannot use the reverse string methods in the String class. Examples: reverseword("hello") -> "olleh" reverseword("hallo") -> "ollah" i public String reverseWord(String word) Stack character> stack = new Stack ;
Computers and Technology
1 answer:
irga5000 [103]2 years ago
5 0

Answer:

Java Code given below with appropriate comments for better understanding

Explanation:

1.

public String whatAmI(E e) {

//.getClass() returns the runtime class of an object

//.equals() determines whether two objects are equivalent

//by calling a new static instance of a wrapper object we can analyze

//it's class type and compare it to the variable passed in

if(e.getClass().equals(new Integer(1).getClass())) {

return "Integer";

}

else if(e.getClass().equals(new String("1").getClass())) {

return "String";

}

else if(e.getClass().equals(new Double(1.0).getClass())) {

return "Double";

}

else {

return "Who knows!";

}

}

2.

public String reverseWord(String word) {

   Stack<Character> stack = new Stack<Character>();

   for (int i = 0; i < word.length(); i++) {

       stack.push(word.charAt(i));

   }

   String result = "";

   while (!stack.isEmpty()) {

       result += stack.pop();

   }

   return result;

}

You might be interested in
In terms of system thinking, what is process?
Talja [164]

Answer:b) The computer program that processes the data.

Explanation: In the computer system , process is the part of computer program which are responsible for performing of the processing of the data and other functions .The working of the process is associated with the program code and related activities/functions.

Other options that are mentioned in the question are incorrect because they don't describe the process correctly .Thus , the correct answer is option (b).

5 0
2 years ago
Read 2 more answers
Your isp connects to the core routers of the internet via a _____. cable mode spine backbone satellite
melisa1 [442]

fairly certain its backbone

5 0
3 years ago
Robert and Anne, a married couple filing jointly, have an adjusted gross income of $68,676. They claim two exemptions, and can d
artcher [175]

Answer:

the answer is B

Explanation:

Just took the test

8 0
2 years ago
Read 2 more answers
Who created Microsoft​
saveliy_v [14]

Bill Gates and Paul Allen

6 0
3 years ago
Read 2 more answers
What are some innovations that a cell phone has undergone since its original invention?
Contact [7]
- They now have color screens
- Touch screen
- Higher bandwidth due to different radio
- More memory and processing power
- Ability to install and run apps

One could joke that battery life has not improved...
4 0
2 years ago
Other questions:
  • I need help please?!!!
    15·1 answer
  • When you use the bufferedreader class, you must import the ____ package into your program?
    14·1 answer
  • What computer company was founded in 1975?
    6·1 answer
  • The _________ in an internet are responsible for receiving and forwarding packets through the interconnected set of networks and
    10·1 answer
  • What does "CPU" stand for?
    15·2 answers
  • What do libraries allow you to do in C++, and how do you incorporate libraries into a C++ program?
    10·1 answer
  • Where can we buy a cryptocurrency? from below options
    11·1 answer
  • Pleassseeeee helppp!!!!
    7·1 answer
  • LaShawn would like to post photos in a social media app, but the program needs to be modified in order to display a greater vari
    12·2 answers
  • Define the term visual as used in visual programming
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!