Java Interview Questions

Q: What is the difference between an Interface and an Abstract? A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods. Q: How many tags in JSP? A: The Core tag library contains tags for getting, setting, and displaying attribute values; executing tags conditionally; and iterating through collections.There are four types of tags in JSP namely General-Purpose Tags: The general-purpose tags let you add and remove variables, display variable values, and enclose a group of tags within a try-catch block. Conditional Tags: The conditional tags make it easy for you to display text under only certain conditions. Iterator Tags: The iterator tags iterate through collections or tokens, or for a fixed number of times. Not only do the tags perform looping functions, but they can also return a loop status variable as well as store the current member of the collection in a variable. URL-Related Tags: JSTL provides several tags for handling URLs and accessing Web resources. URLs can be difficult to work with when you must worry about URL rewriting (to insert the session ID when the browser doesn't support cookies), URL encoding of parameters, and referencing resources from a separate servlet context within the same servlet container. Q: What is deference between inheritance in C++ and java? A: Java, like C++, supports hierarchies of classes. However, the way that inheritance is implemented in Java differs substantially from the way that it is implemented in C++. Since multiple inheritance is not allowed in Java, then Java class hierarchies are linear. In Java, inheritance is referred to as subclassing. A base class in C++ is referred to as superclass in Java. Q: What is difference between awt and swings? A: awt was mainly built for internet purpose initially. 1.swing components sits on the top of AWT components and do the wiork. 2.AWT components are called HeavyWeight component and Swings are called ligth weight component. 3.swings components are made in purely java and they are platform independent whereas AWT compoents are platform dependent. 4.we can have different look and feel in Swing whereas this feature is not supported in AWT. 5.Swing has many advanced features like JTabel,Jtabbed pane which is not available in awt.. Q: What is applet and survlets and difference between these two? A: An applet is a Java program that runs within a Web browser on the client machine whereas a servlet runs on the Web server. An applet can use the user interface classes like AWT or Swing while the servlet does not have a user interface. The servlet behaves like a CGI script; it waits for HTTP requests from a browser and generates a response that is displayed in the browser. Q: Write a program for reverse the given string with out using predefined functions. prog 1: public class ReverseStringTest { public static void main(String[] args) { String str = "What's going on?"; System.out.println(ReverseString.reverseIt(str)); } } class ReverseString { public static String reverseIt(String source) { int i, len = source.length(); StringBuffer dest = new StringBuffer(len); for (i = (len - 1); i >= 0; i--) dest.append(source.charAt(i)); return dest.toString(); } } prog. 2: import java.util.*; public class StringReverse { public static void main(String[] argv) { String s = "Welcome to Hitechpoint"; Stack myStack = new Stack(); StringTokenizer st = new StringTokenizer(s); while (st.hasMoreTokens()) myStack.push(st.nextElement()); System.out.print('"' + s + '"' + " backwards by word is:\n\t\""); while (!myStack.empty()) { System.out.print(myStack.pop()); System.out.print(' '); } System.out.println('"'); } }

No comments:

ONLINE TRAINING

Dear friends we are happy to announce that we entered in corporate training. For the past two years we trained many students, Employees as per industrial requirements. Now we are started online training session for who dont have enough time and who dont want to waste time to come to institutes for learning. We are offering online sessions for Windows server 2003, windows server 2008, MCSE, .NET, Java. MS SQL Server and many more. For more details about course and fee structure please



Followers

Google Pagerank Powered by  MyPagerank.Net