Question

In Java, when is it possible to change the method that is called by typecasting the...

In Java, when is it possible to change the method that is called by typecasting the value to the left of the dot?

a. when the method is overridden

b. when the method is overloaded

c. when the method is static

d. when the method is not static

You can choose more than one answer.

Homework Answers

Answer #1

Answer Option A

Reason: Option A is correct because we can use method overriding by casting an object to the correct type.

Option B is incorrect because method overloading is not used over here for typecasting

Option C is incorrect because when a method is static type casting cannot be done on it

Option D is incorrect because if a method is not static then overriding the method will work in type casting.

If you liked the solution then give a thumbs up ? it will be really appreciated ?

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
-Previously - java class with one static method. In the static method called beforeThis. take 2...
-Previously - java class with one static method. In the static method called beforeThis. take 2 strings as inputs and return a string. Code for the method should look for 1st input String within the 2nd input, and return everything from 2nd input string that comes before. ex: 1st input : "tennis" 2nd input : "A tabletennis is in the basement" method returns: "A table"
Java programming 1) Which among the choices is the following Java expression equivalent to? !((b !=...
Java programming 1) Which among the choices is the following Java expression equivalent to? !((b != 0) || (c <= 5)) Select one: a)       (b != 0) && (c <= 5) b)       (b == 0) && (c > 5) c)       !((b <> 0) && (c <= 5)) d)       (! (b = 0)) && (! (c > 5)) e)       (b == 0) && (c <= 5) 2) The scope of a variable is an important feature in Java, the following variable...
Java Code: Console IO Practice Exercise The purpose of this exercise is to practice console input...
Java Code: Console IO Practice Exercise The purpose of this exercise is to practice console input and output with the Java console. Setup: Create a class called ConsolePractice with a main method. Create a static field in your class that stores a scanner object. You will use this scanner for all user input. private static Scanner scanner = new Scanner(System.in); Part A: Create a static method called “divide”. Your method should do the following: Accept two integers as parameters, a...
Write a Java part code to do the following   : ** Suppose a file called infile stored...
Write a Java part code to do the following   : ** Suppose a file called infile stored in drive D: ,filled with five integers(1000,200,3030,40 and 500) Read  the integers from infile then store them in array called ar[] and print it elements. Method called search( ) to print the location of   value 500. Method called sort() to sort array elements. Build another file called outfile in drive D: to save the sorted array elements . Note : Use ArrayIndexOutOfBoundsException when you use array...
java 1) Create a mutator method called setPosition that accepts one integer parameter. Update the position...
java 1) Create a mutator method called setPosition that accepts one integer parameter. Update the position variable by adding the position to the parameter variable. 2)debug the code public class food { public static void main(String[] args) { Fruits apple = new Fruits(20); // Write the statement to call the method that will increase the instance variable position by 6. Fruits.setPosition(6); apple.getPosition(); } }
Please answer quickly! Thank you. Java: Write a non-static method to be added to a class...
Please answer quickly! Thank you. Java: Write a non-static method to be added to a class that implements a singly linked list of integers. The method is called make_partition() and takes an integer x as input. The method should modify this list by moving all the elements less than x to the front of the list, and all the elements greater than x to the back of the list. It is not the important for the elements to be kept...
Write a Java class called Grades in a class file called Grades.java. 2. Grades reads from...
Write a Java class called Grades in a class file called Grades.java. 2. Grades reads from a text file containing a series of course grades (a value between 0.0 and 100.0) with one grade entry per line. However, the first line in the file is an integer value specifying how many grade entries are contained in the file. 3. The Grades class contains four static methods: a. A method called loadGrades() that opens the file, reads in the data and...
Java program question! If I pass null to a method, how can I use the passed...
Java program question! If I pass null to a method, how can I use the passed value to compare. Here is example code, it might be wrong, please make it could run on eclipse. Public class hw{ public static void main (String args[]) { method1(); } private static void method1() { System.out.println(method(null)); } public static String method(int[] a) { return null; } What I want to get in the output is just "()". It is not just to type the...
Write code in java Implement a method to build an AVL tree out of a sorted...
Write code in java Implement a method to build an AVL tree out of a sorted (ascending order) array of unique integers, with the fastest possible big O running time. You may implement private helper methods as necessary. If your code builds a tree that is other than an AVL tree, you will not get any credit. If your code builds an AVL tree, but is not the fastest big O implementation, you will get at most 12 points. You...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT