What is compile time polymorphism?
Answers were Sorted based on User's Feedback
Answer / pooja
In compile time polymorphism, the overloaded member
functions are selected for invoking, by matching arguments
type,number and sequence by compiler at compile time.
it is also called early or static binding.
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / shubh
When object is bound with its functionality at compile time.
Then polymorphism is called compile time polymorphism.
Function overloading is a way to achieve compile time
polymorphism in java.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / charles i
overloading method and the compiler has to decide when to
call the method..
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / coolm
Function and operator overloading is compile time polymorphism.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sadikhasan palsaniya
method overloading with final keyword is known as compile
time polymorphism.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ahmad salam mehsu
This is another type of polymorphism also called as compile
time polymorphism or static binding. Using template provides
compile-time polymorphism.
So "compile time polymorphism" means function overloading.
It applies only to functions because they're all you can
overload.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / laukik
Compile Time Polymorphism in Java is when you have the
several methods with same name and different parameters and
compiler has to decide how to select which method has to run
based on the arguments hence the name Compile time
polymorphism or method overloading.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / oneeb dadgar
It is also known as a Early-Binding.In this method, overloading method performs the different tasks at the different input parameters.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dimuth lasantha
One method can use another method using changes functions and operations.We can can mention it as method overloading.its means method name can't be change but method body and return type can be change.
| Is This Answer Correct ? | 0 Yes | 2 No |
Can we declare a class as abstract without having any abstract method?
Question 5 [15] Consider the following classes, illustrating the Strategy design pattern: import java.awt.*; abstract class Text { protected TextApplet tA; protected Text(TextApplet tApplet) { tA = tApplet; } abstract public void draw(Graphics g); } class PlainText extends Text { protected PlainText(TextApplet tApplet) { super(tApplet); } public void draw(Graphics g) { g.setColor(tA.getColor()); g.setFont(new Font("Sans-serif", Font.PLAIN, 12)); g.drawString(tA.getText(), 20, 20); } } class CodeText extends Text { protected CodeText(TextApplet tApplet) { super(tApplet); } public void draw(Graphics g) { g.setColor(tA.getColor()); g.setFont(new Font("Monospaced", Font.PLAIN, 12)); g.drawString(tA.getText(), 20, 20); } } public class TextApplet extends java.applet.Applet { protected Text text; protected String textVal; protected Color color; public String getText() { return textVal; } public Color getColor() { return color; } public void init() { textVal = getParameter("text"); String textStyle = getParameter("style"); String textColor = getParameter("color"); if (textStyle == "code") text = new CodeText(this); else text = new PlainText(this); if (textColor == "red") color = Color.RED; else if (textColor == "blue") color = Color.BLUE; else color = Color.BLACK; } public void paint(Graphics g) { text.draw(g); 10 } } The Text class is more complicated than it should be (there is too much coupling between the Text and TextApplet classes). By getting rid of the reference to a TextApplet object in the Text class and setting the colour in the paint() method, one could turn the Text class into an interface and simplify the strategy classes considerably. 5.1 Rewrite the Text and PlainText classes to do what is described above. (6) 5.2 Explain the consequent changes that are necessary to the TextApplet class. (4) 5.3 Write an additional strategy class called FancyText (to go with your simplified strategy classes) to allow fancy text to be displayed for the value "fancy" provided for the style parameter. It should use the font Font ("Serif", Font.ITALIC, 12). (3) 5.4 Explain what changes are necessary to the TextApplet class for this. (2)
Which class is the superclass for every class in java programming?
Difference between predicate, supplier and consumer ?
Difference between Reader/Writer and InputStream/Output Stream?
9 Answers Adobe, Kirusa, Verizon,
Where are register variables stored?
which methods consisting of the serilizable interface?
Why java is secure? Explain.
How many threads does a core java have?
Can we override compareto method?
What is nested top-level class?
Can we increase array size dynamically in java?