The getValue() method is overridden in two ways. Which one is correct?1.

public class Test {

public static void main(String[] args) {

A a = new A();

System.out.println(a.getValue());

}

class B {

public String getValue() {

return "Any object";

}

class A extends B {

public Object getValue() {

return "A string";

}

2.

public class Test {

public static void main(String[] args) {

A a = new A();

System.out.println(a.getValue());

}

class B {

public Object getValue() {

return "Any object";

}

class A extends B {

public String getValue() {

return "A string";

}

a.I
b.II
c.Both I and II
d.Neither

Answers

Answer 1
Answer:

Answer:

Hi there KatiesTomato! The answer is: b. II

Explanation:

Java allows us to override a method defined in the main or Parent class by re-defining it in the child class. In the question, the first option gives us code that will throw an error because the String method getValue() in class B is being overridden by a method in class A which returns an Object which is also a String. So the compiler will throw an error that type Object is not compatible with String. Option 2 will compile successfully and return a String because the Object is allowed to be converted to a String.


Related Questions

Plz answer me will mark as brainliest ​
A(n) _____ is a harmful program that resides in the active memory of the computer and duplicates itself.WormVirusKeyloggerTimebomb
The sql standard prescribes three different types of __________ operations: left, right, and full.
Insert the missing code in the following code fragment. This fragment is intended to implement a method to set the value stored in an instance variable. Public class Employee { Private String empID; Private boolean hourly; ) . . _______ { Hourly = isHourly; } } A) public void setHourly(String isHourly) B) public void getHourly() C) public boolean getHourly() D) public boolean setHourly(boolean isHourly)
Write a function in Matlab which takes as input an integer x and as output returns the biggest prime number that is less than or equal to x. For example, if the input is 7, the output would be 7. If the input is 40, the output would be 37. (Reminder: isprime.)

Bargain Bob's auto dealership sells vehicles. He sells Chrysler, Jeep, and Dodge brand vehicles. He tracks customer and manufacturer. Bob tracks only the main owner—all co-owners and co-signers are recorded elsewhere.Based on the description above, what is the maximum cardinality between each instance of "Customer" and "Vehicle?"

Answers

Based on the given description in the question, the maximum cardinality assignment of the customer and vehicle is; one customer to one vehicle mapping

Cardinal Mapping

Cardinality is simply defined as the mapping of entities or group of entities to a certain cardinal value. This means that cardinality seeks to highlight the relationship between two objects such as eggs in a crate or shoes on a rack.

Now, in this question, we see that the car dealer sells one car to a customer and tracks the customer and manufacturer for that particular vehicle. This is simply 1 to 1 mapping and as such the maximum cardinality assignment of the customer and vehicle is one (1) to one (1) mapping.

Read more on Mapping at; brainly.com/question/1625866

Answer:

Customer(1) - (1) Vehicle.

Explanation:

Cardinality is the mapping of entities or group of entities to a cardinal value. It tries to show the relationship between two objects like a cups in a shelf or plates in racks.

The car dealer in the question, sells one car to a customer and keep or prioritise the record of the main owner of the acquired vehicle. So the maximum cardinality assignment of the customer and vehicle is one (1) to one (1) mapping.

What is the output, if userVal is 5? int x; x = 100; if (userVal != 0) { int tmpVal; tmpVal = x / userVal; System.out.print(tmpVal); }

Answers

Answer:

The output is 20

Explanation:

This line divides the value of x by userVal

tmpVal = x / userVal;

i.e.

tmpVal = 100/5

tmpVal = 20

This line then prints the value of tmpVal

System.out.print(tmpVal);

i.e 20

Hence, The output is 20

Final answer:

The provided Java code checks if the variable userVal does not equal 0. As this is the case when userVal is 5, another variable tmpVal is assigned the value of another variable x (which is 100) divided by userVal. Hence, the output of the code would be 20.

Explanation:

In the given piece of code, the variable userVal is assigned a value of 5. The program also contains a variable x which is assigned a value of 100. An if statement checks whether userVal does not equal 0 - since 5 != 0, the condition is true. A new variable tmpVal is then declared and assigned the value of x divided by userVal, so tmpVal equals 100 / 5, which is 20. So, the output of this code when userVal is 5 would be 20.

Learn more about Java Programming here:

brainly.com/question/34106786

#SPJ3

C programmig : Output all combinations of character variables a, b, and c, using this ordering:abc acb bac bca cab cbaSo if a = 'x', b = 'y', and c = 'z', then the output is: xyz xzy yxz yzx zxy zyxYour code will be tested in three different programs, with a, b, c assigned with 'x', 'y', 'z', then with '#', '$', '%', then with '1', '2', '3'.

Answers

Answer:

// Here is code in C.

#include "stdio.h"

// create function to print all the combinations

void print_combi(char a,char b,char c)

{

// print all combinations of three characters

   printf("%c%c%c %c%c%c %c%c%c %c%c%c %c%c%c %c%c%c\n",a,b,c,a,c,b,b,a,c,b,c,a,c,a,b,c,b,a);

}

// driver function

int main(void)

{

// create 3 char variable and initialize

char a='x',b='y',c='z';

// call the function

print_combi(a,b,c);

printf("\n");

// initialize with different character

a='1',b='2',c='3';

// call the function

print_combi(a,b,c);

printf("\n");

// initialize with different character

a='#',b='$',c='%';

// call the function

print_combi(a,b,c);

printf("\n");

return 0;

}

Explanation:

Create three char variables a, b, c. First initialize them with x, y, z. then call  the function print_combi() with three parameters . this function will print all the combinations of those characters.We can test the function with different values of all the three char variables.

Output:

xyz xzy yxz yzx zxy zyx

123 132 213 231 312 321

#$% #%$ $#% $%# %#$ %$#

A C program to find all combinations of character variables:

void main ()

{

       char f;

       char s;

       char t;

       f = 'x';

       s = 'y';

       t = 'z';

       System.out.print("" + f + s + t + " " + f + t + s + " " + s +f + t +

       " " + s + t + f + " " + t + f + s + " " + t + s + f);

  }

}

Write a C++ program to find the number of pairs of integers in a given array of integers whose sum is equal to a specified number.

Answers

Answer:

int main()

{

   int A1= {5,3,4,8,9,0,7};

   int SArri1 = sizeof(A1);

  printf("Original array: ");

   

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

   printf("", A1[i] );

   

   int i, sum = 20, n= 0;

   printf("\nArray pairs whose sum equal to 20: ");

   

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

       for (int j=i+1; j<SArri1; j++)

           if (A1[i]+A1[j] == sum)

             {

              Printf(“\n”, array1[i])

Printf(“,”,array1[j]);

               n++;

             }

 

  printf("\nNumber of pairs whose sum equal to 20: ",n)

   return 0;

}

Explanation:

First of all, you should create the array of integers, and put random numbers. Then you have to save in a constant the size of the array (in this  code is called SArr1) With a for you can print all the numbers that are on the array because then you will print all array pairs whose sum is equal to  a specified numer. in this code we are going to use 20.

then with a condition (if) you are going to compare one of number of the array with all the others and check if its equal to 20. If yes, it going to print the numbers that answer to that condition and it's going to add +1 to the variable n (for this you will need to use two bucles for)

Then you can print the number of pairs whose sum is equal to 20 by printing n

In almost all cases, touching power lines or coming into contact with energized sources will result in what? Select the best option. First degree burns
Severe injuries or death
Neurological damage
Amputations

Answers

In almost all cases, touching power lines or coming into contact with energized sources will result in Severe injuries or death. Thus, option second is correct.

What is energized sources?

Electrical, mechanical, chemical, pneumatic, chemical, thermal, and other energy sources in machinery and equipment can be harmful to employees.

De-energization may entail turning off a machine and unplugging it, or removing a switch before applying a lock to prevent the equipment from being accidentally starting up. Lockout can be enforced once energization is complete.

Touching electricity lines or making contact with electrical sources will almost always result in severe injury or death. As a result, option two is correct.

Learn more about sources here:

brainly.com/question/2000970

#SPJ2

Answer:

Severe injuries or death

Explanation:

Implement the logic function ( , , ) (0,4,5) f a b c m =∑ in 4 different ways. You have available 3to-8 decoders with active high (AH) or active low (AL) outputs and OR, AND, NOR and NAND gates with as many inputs as needed. In every case clearly indicate which is the Most Significant bit (MSb) and which is the Least Significant bit (LSb) of the decoder input.

Answers

Answer:

See explaination

Explanation:

Taking a look at the The Logic function, which states that an output action will become TRUE if either one “OR” more events are TRUE, but the order at which they occur is unimportant as it does not affect the final result. For example, A + B = B + A.

Alternatively the Most significant bit which is also known as the alt bit, high bit, meta bit, or senior bit, the most significant bit is the highest bit in binary.

See the attached file for those detailed logic functions designed with relation to the questions asked.