:: Home Page
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   Errors
   Testimonials Refer this Site  Refer This Site to Your Friends  Site Map  Contact Us      
 Categories >> Software >> Java Related >> Java J2EE >> Core Java
Suggest New Category 


Question Asked @ Answers Views     Select
What is the life-cycle of an object?    1  1
How is object created in java?    1  1
What is an object in Java and what are its benefits?    1  4
What is Difference between Serializable and Externalizable in Java serialization?    1  39
What is difference between compatible and incompatible changes in serialization?    1  39
What is deserialization and how do we do deserialization?    3  31
What is serialVersionUID and what is its need?    1  29
How do we make a class serialize?    3  37
Why do we need main method to execute a java program?    1  100
What is difference between overloading and overriding?    2  108
Describe OOP in java?    2  85
What are the uses of final, finally and finalize in java?    1  58
Are the equals() and hashCode() protected methods of object class?    1  44
How to override equals() and hashCode() method in java?    1  44
Why do we need to override equals() and hascode() method of object class?    1  38
E-Mail New Answers        Answer Selected Questions        Post New core-java Questions
 [1]    2  ... 10   ... 19   ... 28   ... 37   ... 46   ... 55   ... 64   ... 73   ... 82   ... 91   ... 100   ... 109   ... 118    Next
Un-Answered Questions
 Question Views   Select
How to provide security in java 648
What are invisible components?. 639
Say you want to store the information about a number of pets in an array. Typical information that you could store for each pet (where relevant) would be • Breed of animal • Animal's name • Its birth date • Its sex • Whether it has been sterilised or not • When it is due for its next inoculation • When it last had its wings clipped For each type of pet (eg. dog, cat or bird) you would typically define a class to hold the relevant data. Note: You do not need to implement these classes. Just answer the following questions. 3.1.1 What would be the advantage of creating a superclass (eg. Pet) and declaring an array of Pet objects over simply using an array of Objects, storing each of the instances of the different pet classes (eg. Dog, Cat or Bird) in it? 3.1.2 Would you define Pet as a class or as an interface? Why? (2) (2) 332
What are advantages of using Java?s layout managers than windowing systems? 822
Write an algorithm program in java for the following question.. 1) S is a set of integers.X is an integer obtained by sum of two digits in S. Write logic for whether or not the X is from the S. The time of algorithm should not exceed o(n logn). 496
what is dafault constructor and paramererised constructor with example? 582
What are the differences between Java 1.0 and Java 2.0? 496
which pattern is default in scanner package? 734
Explain JSP life cycle 888
Why are the destructors for base class and derived class called in reverse order when the program exits 631
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) 448
who can i handle multiple client in RMI 367
In a container there are 5 components. I want to display all the component names, how will you do that? 470
ublic class Java_Coding_Samples { public static void JavaHungr(NumberFormatException ae){ System.out.println("integer"); } public static void JavaHungry(Exception e){ System.out.println("string"); } public static void JavaHungry(ArithmeticException ae){ System.out.println("object"); } public static void main(String[] args) { JavaHungry(null); } 159
E-Mail New Answers        Answer Selected Questions