The Artima Developer Community
Sponsored Link

Java Buzz Forum
Friday Java Quiz: Know Your Class Loading Moments

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: Know Your Class Loading Moments Posted: May 20, 2011 1:00 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Friday Java Quiz: Know Your Class Loading Moments
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

I haven't posted much recently. Nobody I know posts much any more. I guess Twitter is the thing now. But this one is longer than 140 characters.

Q: Will the following Java program compile? Run without exceptions? If so, what does it print when run?

class Foo { 
    public static int i;
    static { System.out.println("Foo");} 
}
 
class Bar extends Foo { 
    public static int j;
    static { System.out.println("Bar");} 
}
 
public class Main { 
    public static int k = Bar.i; 
    public static void main(String[] args) {} 
}

Lenient rules apply for this quiz: You are allowed to Google. You are allowed to read your copy of the Java Language Specification. But you do need to write down your answer before you compile the code.

Read: Friday Java Quiz: Know Your Class Loading Moments

Topic: New in 10.5: Attach debugger to a running Android process Previous Topic   Next Topic Topic: JavaOne 2011 Call for Papers

Sponsored Links



Google
  Web Artima.com   

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