The Artima Developer Community
Sponsored Link

Java Buzz Forum
Friday Java Quiz: Enhanced for Loop

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Friday Java Quiz: Enhanced for Loop Posted: Sep 26, 2008 7:28 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Friday Java Quiz: Enhanced for Loop
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

Q: Will the following program compile? Run without exceptions? If so, what will it print?

public class Foo {
  public static void main(String[] args) {
    String[][] sss = new String[2][];
    int c = 0;
    for (String[] ss: sss) {
      ss = new String[3];
      for (String s: ss) {
        s = "Slot # " + c++;
      }
    }
    for (String[] ss: sss) {
      for (String s: ss) {
        System.out.println(s);
      }
    }
  }
}

Strict rules this week: you must not actually compile the program before answering the questions.

Read: Friday Java Quiz: Enhanced for Loop

Topic: Sun has posted an early draft review of Java Specification Request 314: JavaServer Faces 2.0. Previous Topic   Next Topic Topic: Friday Java Moral Dilemma: import com.sun.net.httpserver.HttpServer;

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use