Post New FCUK General Knowledge_Current Affairs Interview Questions
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)
How to pass data to a program that is coded in an exec statement?
How would you define a protected member in a python class ?
What relevant domain experience does the team have? - Venture Capitalists
What is @manytoone fetch fetchtype lazy?
How many rejections do you take in a typical week?
hiiiii Respected sir/madam gd morning sir/Madam Can you please give me following questions of answer.? 1) what is the main difference between Current Assests and Fixed Assests? 2) working capital Management? why? which steps requried for working capital management at the statring day of the any type of business? 3) Ratio analysis? why? (Note: 1,on the above questions of answer the following points are exculded) 1) object 2) theory 3) features (Note :2,on the aove questions of answer the follwing points are inculded) 1) Practical oriented 2) aspects of business please reply..................
What are the 4 types of files we need to copy to the standard folder?
How do you copy formatting?
What is the concept of Association?
State the rules to be followed during infix to prefix conversions?
What is the output of TextWriterTraceListener redirected?
What is a sympy?
What is the diff between vb mdi form and .net mdi form?
What are different states of an entity bean in hybernate?