![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Moderator Join Date: Feb 2006
Posts: 1,419
Thanks: 0
Thanked 29 Times in 23 Posts
Rep Power: 21 | Find the output of the following[/B] Question 1) Which statement is true of the following code?public class Agg{ public static void main(String argv[]){ Agg a = new Agg(); a.go(); } public void go(){ DSRoss ds1 = new DSRoss("one"); ds1.start(); } } class DSRoss extends Thread{ private String sTname=""; DSRoss(String s){ sTname = s; } public void run(){ notwait(); System.out.println("finished"); } public void notwait(){ while(true){ try{ System.out.println("waiting"); wait(); }catch(InterruptedException ie){} System.out.println(sTname); notifyAll(); } } } 1) It will cause a compile time error 2) Compilation and output of "waiting" 3) Compilation and output of "waiting" followed by "finished" 4) Runtime error, an exception will be thrown Question 2)Which of the following methods can be legally inserted in place of the comment //Method Here ? class Base{ public void amethod(int i) { } } public class Scope extends Base{ public static void main(String argv[]){ } //Method Here } 1) void amethod(int i) throws Exception {} 2) void amethod(long i)throws Exception {} 3) void amethod(long i){} 4) public void amethod(int i) throws Exception {} Question 3)Which of the following will output -4.0 1) System.out.println(Math.floor(-4.7)); 2) System.out.println(Math.round(-4.7)); 3) System.out.println(Math.ceil(-4.7)); 4) System.out.println(Math.min(-4.7)); Question 4)What will happen if you attempt to compile and run the following code? Integer ten=new Integer(10); Long nine=new Long (9); System.out.println(ten + nine); int i=1; System.out.println(i + ten); 1) 19 followed by 20 2) 19 followed by 11 3) Compile time error 4) 10 followed by 1 Question 5)If you run the code below, what gets printed out? String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd)); 1) Bic 2) ic 3) icy 4) error: no method matching substring(int,char) NOTE * please do not copy & paste answers from other site. It leads to banning of your user name Answer 1) 4) Runtime error, an exception will be thrown A call to wait/notify must be within synchronized code. With JDK1.2 this code throws the error message java.lang.IllegalMonitorStateException: current thread not owner at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:424) at DSRoss.notwait(Compiled Code) at DSRoss.run(Agg.java:21) Answer 2)2,3 Options 1, & 4 will not compile as they attempt to throw Exceptions not declared in the base class. Because options 2 and 3 take a parameter of type long they represent overloading not overriding and there is no such limitations on overloaded methods. Answer 3)3) System.out.println(Math.ceil(-4.7)); Options 1 and 2 will produce -5 and option 4 will not compile because the min method requires 2 parameters. Answer 4)3) Compile time error The wrapper classes cannot be used like primitives. Depending on your compiler you will get an error that says someting like "Error: Can't convert java lang Integer". Wrapper classes have similar names to primitives but all start with upper case letters. Thus in this case we have int as a primitive and Integer as a wrapper. The objectives do not specifically mention the wrapper classes but don't be surprised if they come up. Answer 5)2) icThis is a bit of a catch question. Anyone with a C/C++ background would figure out that addressing in strings starts with 0 so that 1 corresponds to i in the string Bicycle. The catch is that the second parameter returns the endcharacter minus 1. In this case it means instead of the "icy" being returned as intuition would expect it is only "ic".
__________________ \"Winners don\'t do different things.They do things Differently\" |
| | |
| The Following User Says Thank You to keerthi For This Useful Post: | yathish (31-12-06)
|
| | #2 (permalink) |
| Senior Member Join Date: Jun 2006 Location: India
Posts: 114
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 7 | hi Keerthi, very nice,the questions are very logical
__________________ A PEACEFUL MIND ALWAYS GENERATES POWER |
| | |
| The Following User Says Thank You to rachana For This Useful Post: | vijayamanivannan (18-10-06)
|
| | #3 (permalink) |
| Junior Member Join Date: Aug 2006 Age: 25
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 4 | Dear keerthi I am Vijay looking for JOB and i need to know EJB and Structs pls help me |
| | |
| | #4 (permalink) |
| Junior Member Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 | Re: Java Contest-13 with answers Hello To all sureshkumar.net forums community this is Sridevi, i am looking for job in Java/J2EE and and i want to know what type of questions will be asked during interview related to Java like servlets, jsp, ejbs,struts, jdbc, rmi etc. |
| | |
| | #5 (permalink) |
| Junior Member Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 | Re: Java Contest-13 with answers hi keerthi, Questions are nice.Plz give me faq on packages ![]() |
| | |
| | #6 (permalink) | |
| Unregistered
Posts: n/a
| Quote:
Question: What is J2EE? Answer: J2EE Stands for Java 2 Enterprise Edition. J2EE is an environment for developing and deploying enterprise applications. J2EE specification is defined by Sun Microsystems Inc. The J2EE platform is one of the best platform for the development and deployment of enterprise applications. The J2EE platform is consists of a set of services, application programming interfaces (APIs), and protocols, which provides the functionality necessary for developing multi-tiered, web-based applications. You can download the J2EE SDK and development tools from http://java.sun.com/. Question: What do you understand by a J2EE module? Answer: A J2EE module is a software unit that consists of one or more J2EE components of the same container type along with one deployment descriptor of that type. J2EE specification defines four types of modules: a) EJB b) Web c) application client and d) resource adapter In the J2EE applications modules can be deployed as stand-alone units. Modules can also be assembled into J2EE applications. Question: Tell me something about J2EE component? Answer: J2EE component is a self-contained functional software unit supported by a container and configurable at deployment time. The J2EE specification defines the following J2EE components: Application clients and applets are components that run on the client. Java servlet and JavaServer Pages (JSP) technology components are Web components that run on the server. Enterprise JavaBeans (EJB) components (enterprise beans) are business components that run on the server. J2EE components are written in the Java programming language and are compiled in the same way as any program in the language. The difference between J2EE components and "standard" Java classes is that J2EE components are assembled into a J2EE application, verified to be well formed and in compliance with the J2EE specification, and deployed to production, where they are run and managed by the J2EE server or client container. Question: What are the contents of web module? Answer: A web module may contain: a) JSP files b) Java classes c) gif and html files and d) web component deployment descriptors Question: Differentiate between .ear, .jar and .war files. Answer: These files are simply zipped file using java jar tool. These files are created for different purposes. Here is the description of these files: .jar files: These files are with the .jar extenstion. The .jar files contains the libraries, resources and accessories files like property files. .war files: These files are with the .war extension. The war file contains the web application that can be deployed on the any servlet/jsp container. The .war file contains jsp, html, javascript and other files for necessary for the development of web applications. .ear files: The .ear file contains the EJB modules of the application. Question: What is the difference between Session Bean and Entity Bean? Answer: Session Bean: Session is one of the EJBs and it represents a single client inside the Application Server. Stateless session is easy to develop and its efficient. As compare to entity beans session beans require few server resources. A session bean is similar to an interactive session and is not shared; it can have only one client, in the same way that an interactive session can have only one user. A session bean is not persistent and it is destroyed once the session terminates. Entity Bean: An entity bean represents persistent global data from the database. Entity beans data are stored into database. Question: Why J2EE is suitable for the development distributed multi-tiered enterprise applications? Answer: The J2EE platform consists of multi-tiered distributed application model. J2EE applications allows the developers to design and implement the business logic into components according to business requirement. J2EE architecture allows the development of multi-tired applications and the developed applications can be installed on different machines depending on the tier in the multi-tiered J2EE environment . The J2EE application parts are: a) Client-tier components run on the client machine. b) Web-tier components run on the J2EE server. c) Business-tier components run on the J2EE server and the d) Enterprise information system (EIS)-tier software runs on the EIS servers Question: Why do understand by a container? Answer: Normally, thin-client multi-tiered applications are hard to write because they involve many lines of intricate code to handle transaction and state management, multithreading, resource pooling, and other complex low-level details. The component-based and platform-independent J2EE architecture makes J2EE applications easy to write because business logic is organized into reusable components. In addition, the J2EE server provides underlying services in the form of a container for every component type. Because you do not have to develop these services yourself, you are free to concentrate on solving the business problem at hand In short containers are the interface between a component and the low-level platform specific functionality that supports the component. The application like Web, enterprise bean, or application client component must be assembled and deployed on the J2EE container before executing. Question: What are the services provided by a container? Answer: The services provided by container are as follows: a) Transaction management for the bean b) Security for the bean c) Persistence of the bean d) Remote access to the bean e) Lifecycle management of the bean f) Database-connection pooling g) Instance pooling for the bean Question: What are types of J2EE clients? Answer: J2EE clients are the software that access the services components installed on the J2EE container. Following are the J2EE clients: a) Applets b) Java-Web Start clients c) Wireless clients d) Web applications | |
|
| The Following User Says Thank You to For This Useful Post: | naveen20.1984 (18-01-07)
|
| | #7 (permalink) |
| Junior Member Join Date: Apr 2006 Location:
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 | Re: Java Contest-13 with answers Hi Friends, My name is Vinod and I want to know about RMI (Remote Method Innovacation) please if any body can give me a detailed information about RMI from the begining.
__________________ vinod |
| | |
![]() |
| Tags |
| answers , contest13 , java |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| More Interview Questions Here... |