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]
3 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]3 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
Like when writing a paragraph, the subject becomes the __________ of the photograph.
Natali5045456 [20]
It is A, the theme is the subject.
8 0
3 years ago
Which of these inventions was necessary to permit magnetic recording?
eimsori [14]
It’s C vinyl records permit magnetic fields
4 0
3 years ago
Read 2 more answers
true or false : The incorrect attitude towards driving is the cause of most collisions among teenage drivers.
natulia [17]
That is true your state of mind is what matters most 

4 0
3 years ago
Read 2 more answers
Olivia works at a company that creates mobile phones. She wanted to estimate the mean amount of time their new phone's battery l
Kisachek [45]

An swer:  

                               

 E. xpl an ation:    

                               

3 0
3 years ago
1. State the types of programming language
timama [110]

Answer:

All four questions are explained below :

Explanation:

  1. The types of programming language are: Procedural Programming Language, Functional Programming Language , Object-oriented Programming Language, Scripting Programming Language,Logic Programming Language. For example: C, C++, Java, FORTRAN, PHP language etc.
  2. Imperative language means code is executed line by line, in sequence. And declarative language means that the program itself specifies what next is to be done not how it is done.
  3. One line of 2nd generation is equivalent to one line of object code.
  4. One line of 3rd generation is equivalent to many lines of object code.
8 0
3 years ago
Other questions:
  • System Architecture: Describe the system architecture. Specifically, be sure to address the corporate organization and culture,
    10·1 answer
  • Without protocols the information sent and received through the Internet would never reach its intended target and even if it di
    6·1 answer
  • Write the name of the tab, the command group, and the icon that you need to use to justify text
    9·1 answer
  • Communications that take the form of electronic junk mail or unsolicited e-mail are referred to as
    13·2 answers
  • A thermostat with the processor program to control temperature is an example of what kind of computer
    6·1 answer
  • You want to use the randrange() method. Which line will allow you to enter the following code in IDLE?
    12·2 answers
  • Which of the following statements is TRUE of a peer-to-peer network?
    10·1 answer
  • Select the correct answer.
    5·1 answer
  • In testing you find that one of the tables in your database has multiple versions of one of the columns, and updating the inform
    6·1 answer
  • If you anticipate running a particular query often, you can improve overall performance by saving the query in a special file ca
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!