java question related to objects

Ads
 

java question related to objects

what is the output of the following code?

public class objComp { Public static void main(String args[]) { Int result = 0; objComp oc= new objComp(); object o = oc; if( o==oc) result =1; if(o!=oc) result = result+10; if (o.equals(oc)) result=result+100; if (oc.equals(o)) result=result+1000; system.out.println(result); } }

View Answers

March 16, 2011 at 12:05 PM

There were so many errors. After removing all those error, we get the output: 1101

public class objComp {
    public static void main(String args[]) {
        int result = 0; 
        objComp oc= new objComp(); 
        Object o = oc; 
        if( o==oc)
        result =1; 
        if(o!=oc)
        result = result+10;
        if (o.equals(oc))
        result=result+100;
        if (oc.equals(o))
        result=result+1000;
        System.out.println(result);
        }
        }

Ads









Related Tutorials/Questions & Answers:
java question related to objects
java question related to objects  what is the output of the following code? public class objComp { Public static void main(String args[]) { Int result = 0; objComp oc= new objComp(); object o = oc; if( o==oc) result =1; if(o
java related question
java related question  How can we make a program in which we make mcqs question file and then make its corresponding answer sheet....like if we make 15 mcqs then java should generate it answer sheet of 15 mcqs with a,b,c d
Advertisements
Java and jvm related question
Java and jvm related question  What is difference between java data types and jvm data types
Java Related Question
Java Related Question  hi, Why java doesn't has primitive type as an object,whats an eligibility to have a primitive type as an object by the languages
Java Related Question
Java synchronized method  Dear Friend, I have written below program for synchronized method in java but it's not working plz help me. program...","mangal","to","java"}; String name; SynchronizedModel(String nam) { name
Java Related Question
Java synchronized method  Hi, I have written below program for synchronized method in java but it is not working please help me. program...","to","java"}; String name; SynchronizedModel(String nam
java fundamental question related to string
java fundamental question related to string  public class Myclass { Public static void main(String args[]) { String s=??hello??; StringBuffer sb=new StringBuffer(s); Sb.reverse(); If(s==sb) system.out.println(??a
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
Struts related Question
Struts related Question  Hi All, I have a one question on validation framework for client side validation please help me on that. suppose i don't want to put required=true in our JSP then what will happen. what error will come
project related question
project related question  1- how to insert a date through hibernate 2- how to insert exact time ,date separetly in the data base for current time date
string related question
string related question  *q.1>how i dispaly the reference of string variableS ? eg:-String s1="my name"; Sring s2="your name"; here what is address of variable s1 and s2
related to java
related to java  what is mean of }); in java.i know that } is used to close a block of statement,) is used to close a statement and ";"is used after close a statement but i can not usderstood the use of }); together in a java
Restlet Frame work Related question
Restlet Frame work Related question  How to send data from client to server using Restlet framework. The main problem is i am not able to get data at server side. Can anyone post a complete program how to achieve
my question is related to my project viz
my question is related to my project viz   Sir, my project is based on MR tracking system developed using struts framework, it has been developed in Net Beans the whole project is working except a jsp page named dayplan.jsp
Question in Java ??
Question in Java ??   Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number squrfoot
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Objects - Java Beginners
Objects  Hello, assist me crack this programming question. Develop a class to represents a human. The head, arms and legs should be properties of the human and should be represented by separate objects. All of your objects
java question
java question  Hello sir/mam, In collection there is method called toArray() which is used to convert collection into array at tat time array is used 2 store diffferent objects,how is it possible can you describe it briefly
java question
java question  Hello sir/mam, In collection there is method called toArray() which is used to convert collection into array at tat time array is used 2 store diffferent objects,how is it possible can you describe it briefly
java question
java question  Hello sir/mam, In collection there is method called toArray() which is used to convert collection into array at tat time array is used 2 store diffferent objects,how is it possible can you describe it briefly
java question
java question  Hello sir/mam, In collection there is method called toArray() which is used to convert collection into array at tat time array is used 2 store diffferent objects,how is it possible can you describe it briefly
Core Java Interview Question, Interview Question
Core Java Interview Question Page 23  ... and interfaces that are loaded by a Java program. Question: How does a try statement... which causes it to become accessible to reachable objects. Question: When
java question
java question  comparator and comparable   Differences... a comparator object is capable of comparing two different objects. b...: http://www.roseindia.net/help/java/c/comparable-interface.shtml http
Question Java>?
Question Java>?  **ï??· Create a new class called Bank and in the main method use class Account (lab 4) to create an array of 10 accounts. ï??· Enter data for all accounts (account number,name, balance). ï??· Add
java question
java question  what r the Comparator vs Comparable   ... object while a comparator object is capable of comparing two different objects. b... the following links: http://www.roseindia.net/help/java/c/comparable-interface.shtml http
java question :)
java question :)  write java program to use vector in ArrayList with add, remove,sort   import java.util.Vector; public class... Element MUAYAD"); vc.add("Vector Element JAVA"); vc.add("Vector Element
java question
java question   Create a class called Complex to perform arithmetic operations with complex numbers. 1- Use double variables to represent the fields of the class. 2- Provide a no-argument constructor with default values in case
java question
java question  the purpose of defining multiple constructor in java
java question
java question  find the 127 twin pair in java

Ads