Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jeyd

Pages: [1]
1
Java / Re: Java quiz series
« on: December 02, 2013, 04:28:02 pm »
Correct.

Code: (Java) [Select]
public class Home {
   
   private static Home home = new Home();
   private static int DEFAULT_NR_OF_ROOMS = 4;
   private final int rooms;
   
   public Home() {
      rooms = DEFAULT_NR_OF_ROOMS - 1;
   }

   public static void main(String[] args) {
      System.out.println(home.rooms);
   }

}

What does this print and why?

 Well the problem is with int rooms because it is final and at declaration it is not assigned any value. Final variables must be assigned values at their declaration.

2
Java / Re: Java quiz series
« on: December 02, 2013, 01:08:51 pm »
I think it is valid. It is two dimensional String.
              String[][] foo         &&          String[] foo []           &&         String foo [][]         
 all are the same..
  I don't have any new quiz if I'm right.

Pages: [1]