Can someone explain why this happens?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Can someone explain why this happens?

Threaded View

  1. #1
    Join Date
    Oct 2005
    Location
    Chicago
    Posts
    24

    Can someone explain why this happens?

    sample quiz question
    suppose that the following variable declarations have been made:
    int i = 0, int k = 0; String s = "@"; Give the exact output produced by the following code fragments:
    (a)
    System.out.print(i==3); // I know this won't work
    (b)
    System.out.println("Ans: "+(j++)+(++j)+(j++)+(++J); // I don't understand why it gives 0224 and not 1234
    (c)
    for (; k<3; k++) {
    System.out.print(s);
    s = s+s;
    }
    System.out.println(s); // I need to know why it returns 15 @ signs and not seven
    Thanks for the help
    Last edited by Mcody2; 11-02-2005 at 12:34 AM.

Similar Threads

  1. DB2 Visual Explain
    By jim pias in forum Database
    Replies: 0
    Last Post: 03-11-2003, 06:26 PM
  2. Can someone explain what is happening with this code...
    By Robert Tedesco in forum VB Classic
    Replies: 14
    Last Post: 05-05-2002, 07:00 AM
  3. Explain Plan does not provide output
    By shafiq in forum Database
    Replies: 3
    Last Post: 03-31-2002, 01:22 AM
  4. Can some one explain Recordset Page!
    By Johan in forum ASP.NET
    Replies: 0
    Last Post: 03-03-2002, 08:20 AM
  5. Explain >>> in details?
    By ken in forum Java
    Replies: 2
    Last Post: 02-06-2001, 04:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center