• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Greedy :)

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1
I am a bit confused about how Java interprets numbers in binary forms. For example, 99 is 0000 0000 0000 0000 0000 0000 0110 0011
. But -99 is 1111 1111 1111 1111 1111 1111 1001 1101? Why isn't -99 1000 0000 0000 0000 0000 0000 0110 0011?


2
public class Static{

static{
int x=5;
}
}

Does x work the same as a static variable?

3
can we create a static variable inside a method?

4
abstract interface Blah {} legal?

5
Are varibles inside a static method initiated or not initiated like in regular non-static methods?

6.
which 2 are legal methods to override "public void methodA(int i) throws AssertionError

answer is "public void methodA(int i)" and "public void methodA(int i) throws Error" I thought an overriding method can throw a more specific but not a more general exception. Since AssertionError is clearly a subclass of Error, why can an overriding method throw an Error?
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anne Sullivan:
Question 1

Have a look at the following Wikipedia article

Question 2
Question 3
Question 4
Question 5

Why don't try it? You will learn much more if you try it instead of simply reading the answer.

Question 6

Hint. There is a difference between checked and unchecked exceptions.
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 2:
No x will not work as static variable, It will behave as a local variable and its scope is limited to the static block and will not be available outside the block.

Question 3: No we cannot create static variables inside a method. Only local variables or final local variables can be declared inside a method. Static variables are class variables.

Question 4: abstract is a added implictly to every interface declaration by the compiler. So whether you declare interface as abstract or not its implicitly declared as abstract.

Question 5: Am not clear what you are trying to ask.

As Manfred said all these are simple question which can be followed by reading any good java book or by just checking which will help you in understanding concepts better, Just an advice .
Thanks
Deepak
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic