Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

interesting

 
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class ADirtyOne
{
public static void main(String args[])
{
System.out.println(Math.abs(Integer.MIN_VALUE));
}
}

in my comp the output is -2147483648

but the ans given is 0 how come......


---------------------------------------

When does the JVM exit?


After the main method returns.
After all the non demons threads created by the application complete.
After all the demon threads created by the application complete
When a thread executes System.exit();
When an uncaught exception is thrown in a non demon thread.
When an uncaught exception is thrown in a demon thread.
---------------------------------------------------


class which has all its constructors declared as private
1.Cannot be instantiated by any other Outer class.
2.Cannot be extended.

i understand why it can't be instantiated by the other class or other outer class...

but why it can't extend any body please......


-----------------------------
[ May 05, 2005: Message edited by: Parameswaran Thangavel ]
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Answering your first question....
you are right. abs() method returns the same value when the argument given is Integer.MIN_VALUE.
-vinu.
 
vinuharan haran
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answering your third question
The class with all constructors declared private cannot be extended.
The Reason is the derived class constructor has to call the super class constructor.As the superclass constructor has private access ,it is not possible and it results in compiler error.
-vinu.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because of overflow.
Here's something related: http://qa.jtiger.org/GetQAndA.action?qids=15&showAnswers=true
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Integer.MIN_VALUE returns -2147483648. MAX_VALUE of integer is 2147483647. Math.abs() method returns positive no. for example if abs(-10) return 10. so in this case abs(-2147483648) possible to return 2147483648. Here 2147483648 is oveflow value for integer. so it returns -2147483648.

can I any thing misundersatnd here?
 
reply
    Bookmark Topic Watch Topic
  • New Topic