Java J2EE Interview Questions
Questions Answers Views Company eMail

What is garbage collection in Java, and how can it be used ?

Infosys, HCL, Accenture, Wipro, Sara, SITS, TCS,

32 58687

Differentiate Vector and ArrayList?

Wipro, Max Telecom,

6 8492

Differentiate constructor and a method and how are it be used?

Wipro,

7 9023




What is an abstract class?

Wipro, DBS,

7 7857

How can final class be used?

Wipro, Accenture,

5 9800

By what default value is an object reference declared as an instance variable?

Wipro,

1 11036

Java support what type of parameter passing ?

Wipro,

7 12384

Explain the term serialization?

Wipro,

10 10229

Is there is any error if you have multiple main methods in the same class?

Wipro, Infosys,

10 11545

What is Overriding and how can it be used?

Consagous, Wipro,

7 13937

How is serialization used generally ?

3 4838

How are Swing and AWT be differentiated?

Wipro,

3 6127

Explain pass by reference and pass by value?

IBM, Wipro,

8 12442

In which way does a Primitive data type is passed ?

Sun Microsystems,

5 8139

What happens when a main method is declared as private?

L&T, DELL, Infosys, Sun Microsystems,

22 38038







Un-Answered Questions { Java J2EE }

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)

1034


what is a portable component?

861


What is a policy?

1088


how is final different from finally and finalize in java?

1


difference between mqconn and mqconnx?

1






What are mq objects?

1


how to debug applications in message flow?

1


When should a function throw an exception?

2


Is there any way to find whether software installed in the system is registered by just providing the .exe file? I have tried the following code but its just displaying the directory structure in the registry. Here the code : package com.msi.intaller; import java.util.Iterator; import ca.beq.util.win32.registry.RegistryKey; import ca.beq.util.win32.registry.RootKey; public class RegistryFinder { public static void main(String... args) throws Exception { RegistryKey.initialize(RegistryFinder.class.getResource("jRe gistryKey.dll").getFile()); RegistryKey key = new RegistryKey(RootKey.HKLM, "Software\\ODBC"); for (Iterator subkeys = key.subkeys(); subkeys.hasNext();) { RegistryKey subkey = subkeys.next(); System.out.println(subkey.getName()); // You need to check here if there's anything which matches "Mozilla FireFox". } } }

774


in EJB diclare the static methods are not?

2162


How to display names of all components in a Container?

1882


what is session in java?

1


What is JMS API Architecture?

433


what is the broker domain?

1


what is mean by OLE ? Please answer me. Advance thanks.

1577