explain static equal()method?,Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher
explain static equal()method?

More interview questions and answers

Select which one of the critical method is protected:

Select correct option from the followings according to given code: class R4RSCJPTest1 { public int value; public int hashCode() { return 21; } } class R4RSCJPTest2 { public int value; public int hashcode() { return (int)(value^5); } }

Which of the two statements are true when we comparing two instance of same class.Assume that both equals() and hashCode() methods are properly overridden:

Given the following, class MyThread extends Thread { public static void main(String [] args) { MyThread p = new MyThread(); p.run(); } public void run() { for(int a=1;a<3;++a) { System.out.print(a + ".."); } } } what is the result?

Which two of the following methods are defined in class Thread?

Select class which not override the equals and hashCode methods, inheriting them directly from class Object:

The following block of code creates a Thread using a Runnable target: Runnable target = new MyRunnable(); Thread myThread = new Thread(target); Which of the following classes can be used to create the target, so that the preceding code compiles correctly?

Given the following, class MyThread extends Thread { public static void main(String [] args) { MyThread p = new MyThread(); p.start(); System.out.print("one. "); p.start(); System.out.print("two. "); } public void run() { System.out.print("Thread "); } } what is the result of this code?

Select two correct options in case of properly overridden hashCode() and equals() methods:

Given the following, public class MyRunnable implements Runnable { public void run() { // some code here } } which of these will create and start this thread?

What result come when we try to compile and run following code: TreeSet map = new TreeSet(); map.add("one"); map.add("two"); map.add("three"); map.add("four"); map.add("one"); Iterator it = map.iterator(); while (it.hasNext() ) { System.out.print( it.next() + " " ); }

Select collection class.We can accss its element by simple associating a key with element's value and provides synchronization:

Using which collection class we can associate its elements with key valuesand also retrieve objects in FIFO sequence:

Given the following, class MyThread extends Thread { public static void main(String [] args) { MyThread p = new MyThread(); Thread a = new Thread(p); a.start(); } public void run() { for(int x=0;x<3;++x) { System.out.print(x + ".."); } } } what is the result of this code?

Given the following, class myprog { public static void main(String [] args) { printAll(args); } public static void printAll(String[] lines) { for(int i=0;i

Assume we have a class that holds two private variables: x and y. Which of the following pairs can prevent concurrent access problems in that class?

Which class or interface defines the wait(), notify(),and notifyAll() methods?

Which two are true?

Which three are methods of the Object class?

Given the following, public class WaitTest { public static void main(String [] args) { System.out.print("1 "); synchronized(args){ System.out.print("2 "); try { args.wait(); } catch(InterruptedException e){} } System.out.print("3 "); } } what is the result of trying to compile and run this program?

Assume the following method is properly synchronized and called from a thread X on an object Y: wait(2000); After calling this method, when will the thread X become a candidate to get another turn at the CPU?

Which two options are true?

Assume we create a program and one of our threads some lengthy numerical processing. What would be the proper way of setting its priority to try to get the rest of the system to be very responsive while the thread is running?

Which three guarantee that a thread will leave the running state?

Which two options are true ?

Which two are valid constructors for Thread?

Given the following, class MyThread extends Thread { MyThread() { System.out.print(" MyThread"); } public void run() { System.out.print(" bar"); } public void run(String s) { System.out.println(" baz"); } } public class TestThreads { public static void main (String [] args) { Thread t = new MyThread() { public void run() { System.out.println(" foo"); } }; t.start(); } } what is the result?

After line 9.Give no. of objects legal for garbage collection.

Given the following, public class SyncProg { public static void main (String [] args) { Thread p = new Thread() { Foo f = new Foo(); public void run() { f.increase(20); } }; p.start(); } } class Foo { private int data = 40; public void increase(int amt) { int a = data; data = a + amt; } } and assuming that data must be protected from corruption, what—if anything—can we add to the preceding code to ensure the integrity of data?

Given the following, public class Myprog { public static void main (String [] args) { final Foo f = new Foo(); Thread p = new Thread(new Runnable() { public void run() { f.doStuff(); } }); Thread m = new Thread() { public void run() { doStuff(); } }; p.start(); g.start(); } } class Foo { int a = 5; public void doStuff() { if (a < 10) { // nothing to do try { wait(); } catch(InterruptedException ex) { } } else { System.out.println("a is " + a++); if (a >= 10) { notify(); } } } } what is the result?

How will we send the Form Data using GET Request ?

The method ……………is called by the servlet container to notify the servlet that it’s about to be removed from service.

In general, object pooling could substantially.

explain static equal()method?

Select two correct option in case of static nested class:

The ServletConfig object provides the method getInitParameter() to find the values of the :

What are the two objects created when a request is coming from a client to the servlet?

Select correct option which construct an anonymous inner class instance:

Select two correct option which create anonymous inner class from class xyz: class abc { abc(String str) { } abc() { } } class xyz extends abc { xyz() { } xyz(String str) { super(str); } void test() { // Write code here } }

Service method is called only once?

Select correct option when we insert in following code it create instance of xyz: class abc { class xyz { } } class R4RSCJPTest { public static void main (String args[]) { abc a = new abc(); // Write correct code here } }

Select two correct options in case of method local inner class:

The URL for a request from the browser will be :

Which retrieves all cookies sent in a given HttpSErvletRequest request?

What result come when we compile and run following code: public class R4RSCJPTest //1 { //2 public static void main (String args[]) //3 { //4 Object o = new Object() //5 { //6 public boolean equals(Object obj)//7 { //8 return true; //9 } //10 } //11 System.out.println(o.equals("vivek")); //12 } //13 }

What result come when we compile and run following code: public class R4RSCJPTest //1 { //2 public static void main (String args[]) //3 { //4 class SCJPTest //5 { //6 public String name; //7 public SCJPTest(String str)//8 { //9 name = str; //10 } //11 } //12 Object obj = new SCJPTest("welcome");//13 SCJPTest test = (SCJPTest) obj; //14 System.out.println(test.name); //15 } //16 } //17

Which two pieces of information are needed when declaring the web resource collection in the deployment descriptor?

Within a web application deployment descriptor, which maps the com.example.LoginServlet servlet to /utils/LoginServlet?

What result come when we compile and run following code: public abstract class R4RSCJPTest { public int getNum() { return 32; } public abstract class abc { public int getNum() { return 40; } } public static void main (String args[]) { R4RSCJPTest test = new R4RSCJPTest() { public int getNum() { return 54; } }; R4RSCJPTest.abc a = test.new abc() { public int getNum() { return 23; } }; System.out.println(a.getNum() + " " + test.getNum()); } }

Which element, defined as a child of a element in the web application deployment descriptor, guarantees a servlet will be initialized at the time the application is deployed?

What result come when we compile and run following code: public class R4RSCJPTest //1 { //2 public static void main (String args[]) //3 { //4 class SCJPTest //5 { //6 public String name; //7 public SCJPTest(String str) //8 { //9 name = str; //10 } //11 } //12 Object obj = new SCJPTest("welcome"); //13 System.out.println(obj.name); //14 } //15 } //16

What result come when we compile and run following code: public class R4RSCJPTest { R4RSCJPTest() { System.out.print("abc"); } class SCJPTest { SCJPTest() { System.out.print("xyz"); } public void demo() { System.out.print("123"); } } public static void main (String args[]) { R4RSCJPTest test = new R4RSCJPTest(); test.Boo(); } void Boo() { (new SCJPTest() {}).demo(); } }

Which path is required to be present within a WAR file?

Select two correct options from the following:

Which three are described in the standard web application deployment descriptor?

Which defines the welcome files in a web application deployment descriptor?

A RequestDispatcher can be obtained from which two objects?

While using the forward() method if control is transferred from servletX to servletY the URI displayed in the browser would be :

Which is the correct web application deployment descriptor element for defining a servlet initialization parameter?

What is the parameter type for the method setContentType()

Observe the following line of code HttpSession mySession = request.getSession(true);

Http is :

Given: <%-- insert code here --%> Today is: <%= new Date() %> What needs to go on line 1?

Which three occur during JSP page translation?

Given that login.getName() returns a java.lang.String value and given the JSP code: Welcome <%= login.getName() %> Which is equivalent?

At what time the scriptlets will be executed

The JSP developer wants a set of statements to be commented. Which comment style needs to be used in a JSP page?

}” flush=”true” />

, for the scope “session” means

The alternative for is

A tag handler is

. A TLD file is

The doStartTag method can return

The doEndTag method can return

<%@ taglib uri="" prefix="tagPrefix" %>, in this code “uri” is

Jsp expressions are used to

How will we call the method show() to print the output “HAI JSP” from the following code : <%class test { String show() { String s=" HAI JSP"; return s; } } %> <%test t=new test();%>

Components are made by assembling objects

SessionBean is in the package

Chief responsibilities of EJB object :

The return type of create() is :

Protocol used in EJB

What result come when we compile and run following code: class R4RThread extends Thread //1 { //2 public static void main(String args[]) //3 { //4 R4RThread RT = new R4RThread(); //5 RT.go(); //6 } //7 public void go() //8 { //9 for(int i=0;i<=4;++i) //10 { //11 System.out.print(i + "...");//12 } //13 } //14 } //15

Select two correct methods those are defined in Thread class:

What result come when we compile and run following code: class R4RThread extends Thread //1 { //2 public static void main(String args[]) //3 { //4 R4RThread RT = new R4RThread(); //5 RT.start(); //6 System.out.print("1 "); //7 RT.start(); //8 System.out.print("2 "); //9 RT.start(); //10 System.out.print("3 "); //11 } //12 public void run() //13 { //14 System.out.print("Thread "); //15 } //16 } //17

What result come when we compile and run following code: class R4RThread extends Thread //1 { //2 public static void main(String args[]) //3 { //4 R4RThread RT = new R4RThread(); //5 Thread t = new Thread(RT); //6 t.start(); //7 } //8 public void run() //9 { //10 for(int i=7;i>3;--i) //11 { //12 System.out.print(i + "..."); //13 } //14 } //15 } //16

Select correct option. When we insert in following code it will create and start this thread: public class R4RRunnable implements Runnable { public void run() { // write correct code here } }

Exceptions throws in the create method are :

Implementation of business method should be inside :

How many EJB clients can be there for a session bean :

To place a session bean in the Ready state, the container

Select three false statements from the following:

Select two correct methods of Object class:

What result come when we compile and run following code: public class R4RThread extends Thread { public static void main(String argv[]) { R4RThread RT = new R4RThread(); RT.run(); } public void start() { for (int i = 6; i >2; i--) { System.out.println(i); } } }

What result come when we compile and run following code: public class R4RSCJPTest { public static void main(String argv[]) { R4RSCJPTest test = new R4RSCJPTest(); test.go(); } public void go() { R4RThread RT = new R4RThread("one"); RT.start(); } } class R4RThread extends Thread { private String name = ""; R4RThread(String str) { name = str; } public void run() { notwait(); System.out.println("finish"); } public void notwait() { while(true) { try { System.out.println("wait"); wait(); } catch(InterruptedException ie) { } System.out.println(name); notifyAll(); } } }

Select correct option which we used to stop thread against execution:

What result come when we compile and run following code: public class R4RThread extends Thread { private String ThreadName; public static void main(String argv[]) { R4RThread RT = new R4RThread(); RT.go(); } R4RThread() { } R4RThread(String str) { ThreadName = str; } public String getThreadName() { return ThreadName; } public void go() { R4RThread first = new R4RThread("first"); first.start(); R4RThread second = new R4RThread("second"); second.start(); } public void start() { for(int i = 8; i > 5; i --) { System.out.print(getThreadName() +i); try { Thread.sleep(200); } catch(InterruptedException e) { System.out.println(e.getMessage()); } } } }

What result come when we compile and run following code: public class R4RSCJPTest { public static void main(String argv[]) { R4RThread RT1 = new R4RThread("first"); RT1.run(); R4RThread RT2 = new R4RThread("second"); RT2.run(); } } class R4RThread extends Thread { private String name=""; R4RThread(String str) { name = str; } public void run() { for(int i =6; i > 3 ; i--) { try { sleep(100); } catch(InterruptedException e) { } yield(); System.out.print(name); } } }

What result come when we compile and run following code: class R4RThread implements Runnable { int i = 7; public int run() { while (true) { i--; System.out.println("i="+i); } return 1; } }

R4R provides free online tutolrails ,examples for Freshers and experts .We cover core java, tutorials, spring, Hibernate, python, struts, struts 2,c language, spring boot,PHP,MYSQL,C#,ASP.NET,WPF,WCF,Photoshop , JSP, programming, example, Interview questions and answer