ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
 Categories  >>  Software  >>  Java J2EE  >>  Java Related       
 
  Core Java (1203)   Advanced Java (263)   Swing (41)   EJB (124)   Servlets (203)
  Struts (134)   JDBC (159)   JMS (4)   SunOne (3)   J2EE (27)
  Weblogic (34)   Websphere (3)   Java Networking (17)   Java J2EE AllOther (58)
 
Suggest New Category 
 


 

View Page with Answers
  Question  Asked @ Answers Views     select
 
can we create a object in static block class A { static { A a=new A(); } }  5  1595
what is synchronization  3  833
what is Thread?  6  765
what is mutability?which one is mutable String or StringBuffer?and why?give examples of each which shows the mutability of each String or StringBuffer  2  2132
Difference between ligt weight and heavy weight?  3  1541
What is operator?  2  580
What is unicode?  2  607
what is difference between vector and arraylist?. HCL   3  1741
httt method HCL  2  576
what is the use of reference variable  2  796
what is the difference between Cpp And Java Infosys   7  1758
If we disable cookies in our web page, what will happen? Zensar  6  2787
Life Cycle of Thread IBM  3  1785
how to minimize the functionality to will not force garbage collector?  2  653
when we have to use final class in java?  2  1036
E-Mail New Answers        Answer Selected Questions       
 
Prev    1   ... 12    30   [31]    32  ... 45   ... 56   ... 67   ... 78   ... 89   ... 100   ... 111   ... 122   ... 133   ... 144    Next
 
 
 Java J2EE interview questions   Java J2EE Interview Questions  J2ME interview questions   J2ME Interview Questions  Java Related AllOther interview questions   Java Related AllOther Interview Questions
 
 
 
Un-Answered Questions
 
 Question Views Asked at   Select
 
What is isolation level? How to set it? 178  
How native code can be used in a servlet? 278 Tcs
What is a task?s priority? 159  
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) 21  
To identify IDL language what mapping mechanism is used? 237  
Question 7 [8] Consider the following class and answer the questions below it: public class StackWithGuard extends Stack { public StackWithGuard(int size) { super(size); } synchronized public boolean isEmpty() { return super.isEmpty(); } synchronized public boolean isFull() { return super.isFull(); } synchronized public int getSize() { return super.getSize(); } synchronized public void push(Object obj) { try { while (isFull()) { wait(); } } catch (InterruptedException e) {} super.push(obj); COS2144/102 11 notify(); } synchronized public Object pop() { try { while (isEmpty()) { wait(); } } catch (InterruptedException e) {} Object result = super.pop(); notify(); return result; } public static void main(String args[]) { StackWithGuard stack = new StackWithGuard(5); new Producer(stack, 15).start(); new Consumer(stack, 15).start(); } } Note: The Stack class is provided in the Appendix. Note also: The following questions all refer to the pop() method of the StackWithGuard class given above. 7.1 What does the synchronized keyword ensure for this method? (2) 7.2 Why is a while loop used to test whether the stack is empty? In other words, why wouldn't the following if statement be sufficient? if (isEmpty()) { wait(); } (2) 7.3 Why is the result of popping (provided by the inherited pop() method) stored in a temporary variable? In other words, why wouldn't the following statement be sufficient? return super.pop(); (2) 7.4 Why is the while loop placed in a try-catch structure? (2) Appendix The LinkedQueue class: public class LinkedQueue implements Queue { private Node first, last; private int count; public LinkedQueue() { first = last = null; count =0; } public int size() { return count; } public boolean isEmpty() { return (count == 0); 12 } public void enqueue(Object o) { Node node = new Node(); node.element = o; node.next = null; node.prev = last; if (last != null){ last.next = node; } else { last = first = node; } last = node; count++; } public void dequeue() { if ((first!= null) & (first.next!=null)) { first = first.next; first.prev = null; count--; } else { first = last = null; count--; } } public Object front() { return first; } } class Node { Object element; Node next, prev; } The Stack class: public class Stack { protected Object rep[]; protected int top = -1; protected int size = 0; protected int count = 0; public Stack(int size) { if (size > 0) { this.size = size; rep = new Object[size]; } } public boolean isFull() { return (count == size); } public boolean isEmpty() { return (count == 0); } public int getSize() { return size; } public void push(Object e) { if (e != null && !isFull()) { COS2144/102 13 top++; rep[top] = e; count ++; } } public Object pop() { Object result = null; if (!isEmpty()) { result = rep[top]; top--; count--; } return result; } } 28  
How to implement a multithreaded applet? 325  
How to display names of all components in a Container? 226 Wipro
wahts is mean by dynavalidatorform in struts/ 71 SolutionNET
What is your platform?s default character encoding and how to know this? 186 TCS
AS a developer will u create a data source in connection pool? If so how will u do that, how to access the object from connection pool using IRAD tool? 128  
What is JDBC Driver interface?How can you retrieve data from the ResultSet 95 CTS
How MS-Access DB can be accessed over a network, using JDBC API? 281  
diff mvc1 and mvc2 wahts is mean by servlet chaining? 86 SolutionNET
Write the program numbers into words.For example 2345==two thousand three hundred fourty five 46 TCS
Name the components that are termed to be Heavy-weight component but available in Light-weight components? 371  
Tell me the difference between an applet and a Japplet? 231  
kindly can any one post for me portlet,hibernate,spring example code and configuration,and some related tutorials plz its urgent for me....thanks in advance ............ 6  
How task's priority is used in scheduling? 140 HCL
What is Stream Tokenizer? 189  
E-Mail New Answers        Answer Selected Questions
 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com