Answered Questions

  • Sum of two numbers without using arithmetic operators

    ex:int a=10;int b=10;int sum=a+b;without using "+" operator calculate sum

    Star Read Best Answer

    Editorial / Best Answer

    jintojos  

    • Member Since May-2008 | Jul 17th, 2008


    void main()
     {
              int a=10,b=20;
              while(b--) a++;
               printf("Sum is :%d",a);  
     }

    mukesh

    • Aug 10th, 2015

    Simple

    Code
    1.  
    2. void main()
    3. {
    4. int a=5,b=6,c;
    5. c=a-(-b);
    6. printf("%d",c)
    7.  
    8. }

    And

    • Aug 29th, 2012

    For two positive numbers:

    int main(){
    int a = 10;
    int b = 10;

    printf("%d",a ^ b | ((a & b)

  • Can we override the main method?

    Star Read Best Answer

    Editorial / Best Answer

    ashish_setia  

    • Member Since Oct-2006 | Oct 3rd, 2006


    check out this example

    class Checkmain{
    public static void main(String args[]){
    args[1]="ashish";
    System.out.println("hello ");
    }
    }
    class Checkmain1 extends Checkmain{
    public static void main(String args[]){
    System.out.println("how r u");
    }

    }
    class Jo{
    public static void main(String args[]){
    String S[]=new String[10] ;

    Checkmain.main(S);
    Checkmain1.main(S);
    }}

    vivek

    • Aug 26th, 2017

    Yes you can only do that by overriding main method signature for eg main(String[] args) to main(). Certainly there are no other ways to do that because JVM needs strings array arguments to take comma...

    Dharmendra Singh

    • Sep 15th, 2016

    yes we can"java public class HelloWorld { // arguments are passed using the text field below this editor public static void main(String[] args) { String []s =new Str...

  • What is the difference betweem getRequestDispatcher() available as part of ServletContext and ServletRequest

    Delindia fathima

    • Dec 20th, 2011

    requestDispatcher() of a servlet context will takes absolute path Whereas requestDispatcher() of ServletRequest will takes relative path ServletRequest has current request path to evaluate the relati...

    Ambar Ray

    • Sep 4th, 2011

    Hey Folks, In my above post, I missed adding this line which is the MOST IMP change above all one has to make in Tomcat's context.xml file in order to make the above code snipet work-- {geshibot langu...

  • What is the difference between transient variable,volatile variable

    sampra

    • Mar 6th, 2012

    transient variable is the variable which cant be serialized..volatile is useful in multi thread env.each thread has ots own copy to update..in fact it wont update the main memory var ..its update the ...

    Sanjeev

    • Jan 25th, 2012

    If you are working with the multi-threaded programming, the volatile keyword will be more useful. When multiple threads using the same variable, each thread will have its own copy of the local cache f...