• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Iam getting conflicting info please help

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read in order to declare an abstract class you must have at least one abstract method is this true? Also , is null a keyord? I was taking a mock exam and it said it was not. I understand bitwise operators, but I do not understand why this returns 12 instead of 14 System.out.println(010|4);
10 equals 1010
4 equals 0100
result 1110 = 14
can anybody please explain it in plain english, maybe toss in an example?
Thanks
david
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David Moore:
I have read in order to declare an abstract class you must have at least one abstract method is this true? Also , is null a keyord? I was taking a mock exam and it said it was not. I understand bitwise operators, but I do not understand why this returns 12 instead of 14 System.out.println(010|4);
10 equals 1010
4 equals 0100
result 1110 = 14
can anybody please explain it in plain english, maybe toss in an example?
Thanks
david


Yes,an abstract class must have atleast one abstract method.
System.out.println(010|4) is 12.
In java octal numbers are represented with the first digit being 0.
Hence 010 =8.
binary representation of 8=1000
binary representation of 4=0100
hence 8|4=1100 which is nothing but 12.
null is a reserved word.
[This message has been edited by sai challa (edited March 23, 2001).]
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think null is a reserved word.
i JLS these are the keywords
http://java.sun.com/docs/books/jls/first_edition/html/3.doc.html#229308
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have read in order to declare an abstract class you must have at least one abstract method is this true?
Not true, its the other way around. If you declare an abstract method in a class, then that class must be declared abstract. An abstract class may have non-abstract methods.



Also , is null a keyord? I was taking a mock exam and it said it was not.
null, just like true and false is a reserved literal, not a keyword.



I understand bitwise operators, but I do not understand why this returns 12 instead of 14 System.out.println(010|4);
10 equals 1010
4 equals 0100
result 1110 = 14
can anybody please explain it in plain english, maybe toss in an example?

010 is octal representation of decimal 8 or binary 001 000. Therefore, 1000 | 0100 == 1100 (decimal 12).


------------------
~James Baud
He who asks, is a fool for five minutes;
but, he who does not ask, remains a fool forever. (Chinese proverb)
 
David Moore
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks everybody for the help. Iam sure I will have more questions as I prepare for the exam.
david
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
Your first item about abstract class is not correct. The only stipulation that Java imposes is the following:
If any method in a class is abstract, then the class MUST be declared abstract.
The opposite is not imposed (i.e., an abstract class must have an abstract method).
To prove my point compile and run the following example.

Regards,
Manfred.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This would be useful if you didn't want anybody making instances of the abstract class, but you want all of the sub-classes to have functional methods without having to over-ride or implement them.
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Cindy
Your Quote:
This would be useful if you didn't want anybody making instances of the abstract class, but you want all of the sub-classes to have functional methods without having to over-ride or implement them.
My Doubt:
What if i have static methods in abstract class like the following one..? Is it legal?

abstract public class classtest
{
public static void get()
{
int i=3; int j=5;
System.out.println(i*j);
}

public static void main(String args[])
{
classtest.get();
}
}
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic