Wednesday, 23 November 2016

What is the output of following program?

What is the output of following program?


  1. package com.instanceofjava;
  2.  
  3. public class A{

  4.  
  5.  int GetValue()
  6.  {
  7.         return (true ? null : 0);
  8.  }
  9.  
  10.  public static void main(String[] args)  {
  11.  
  12.    A obj= new A();

  13.       obj.GetValue();
  14.  
  15.     }
  16.  
  17. }

 

  1. Exception in thread "main" java.lang.NullPointerException

What is the output of following program?

What is the output of following program?


  1. package com.instanceofjava;
  2.  
  3. public class A{

  4.   
  5.  public static void main(String[] args)  {
  6.  
  7.    Integer i1 = 128;
  8.  
  9.    Integer i2 = 128;
  10.  
  11.      System.out.println(i1 == i2);
  12.  
  13.    Integer i3 = 127;
  14.    Integer i4 = 127;
  15.  
  16.       System.out.println(i3 == i4);
  17.  
  18.     }
  19.  
  20. }

 

  1. false
  2. true

What is the output of following program?

. What is the output of following program?


  1. package com.instanceofjava;
  2. class A
  3. {
  4.     
  5. void method(int i)
  6. {
  7.  
  8.  }
  9.  
  10.     }
  11.  
  12.  class B extends A
  13.  {
  14.  
  15. @Override
  16. void method(Integer i)
  17.  {
  18.  
  19.  }
  20.           


  21. }

 

  1. Compile time Error:The method method(Integer) of type B must override or implement a supertype method

Which line will throw compile time error? 8 or 9?

 Which line will throw compile time error? 8 or 9?


  1. package com.instanceofjava;
  2. class A
  3. {
  4.     
  5. public static void main(String [] args)
  6. {
  7.  
  8.   Integer i = new Integer(null);
  9.   String s = new String(null);
  10.  
  11.  }
  12.  
  13. }

 

  1. Compile time Error at line number 9:The constructor String(String) is ambiguous

System.out.println(null)

Program #1: what will happen when we print System.out.println(null)

System%2Bout%2Bprinln%2Bnull

Program #2: what will happen when we print System.out.println(null) by type casting
   

  1. package com.systemoutprintn;
  2. public class Test {
  3.  
  4.     /**
  5.      * @Website: www.instanceofjava.com
  6.      * @category: System.out.println(null)
  7.      */
  8.  
  9. public static void main(String[] args) {
  10.  
  11.          System.out.println((String)null);//null
  12.          System.out.println((Object)null);//null
  13.          System.out.println((char[])null);
  14.             
  15.  
  16. }
  17.  
  18. }

 Output:
  

  1. null
  2. null
  3. Exception in thread "main" java.lang.NullPointerException
  4.     at java.io.Writer.write(Unknown Source)
  5.     at java.io.PrintStream.write(Unknown Source)
  6.     at java.io.PrintStream.print(Unknown Source)
  7.     at java.io.PrintStream.println(Unknown Source)
  8.     at com.systemoutprintn.Test.main(Test.java:13)

Saturday, 1 August 2015

Deploy NodeJS application on Bluemix+Cloudfare


  1. Create a project on Github or Bitbucket
  2. Development on Cloud9
  3. Deploy application on Bluemix
  4. Configure Cloudfare