Jump to content

Some questions regarding java

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
I have some questions regarding java i hope i get the answers :)

why is java a strongly typed language?
why aren't destructors not used in java?
and what is the concept of unicode in char data type?

#2
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts

ahmed said:

why is java a strongly typed language?
Most likely due to bytecode compilation. Weakly typed languages usually need to be resolved at runtime. Not just that, strongly typed languages tend to be more sensible, and make error checking far easier on the programmer. Then again... that depends on your definition of strongly/weakly typed. One could argue that a programming language is weakly typed if it allows any implicit type conversion, which almost every language permits. But I think the real difference most programmers see is if you can implicitly convert an int to a string and back again, and in that case for Java it's because a string is an object, and Java doesn't support operator overloading.

ahmed said:

why aren't destructors not used in java?
>_> <_< Uhh... but Java doesn't use destructors. Java is a garbage collected language, making memory management a non-issue to the programmer, and as such has no need for destructors. :P

ahmed said:

and what is the concept of unicode in char data type?
I'm d*mn glad Java natively supports (to the point of requiring) Unicode. I think Python should have done the same (and as of 3, it does). Unicode, however, in itself has little to do with Java, and instead has everything to do with building a common medium of exchange for characters across all languages. This is important in the days of the internet since it will be very likely that you're going to be exposed to different languages all over the world. Unicode simply provides a standard mechanism to go by, and is supported natively by almost every computer in existence. In the dark days before character standards, we had all sorts of proprietary systems, in which ASCII eventually won out of, and the ASCII set was mostly retained with the conversion to Unicode. You can learn a lot more than I can teach you from Wikipedia.
Wow I changed my sig!

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts

ahmed said:

I have some questions regarding java i hope i get the answers :)

why is java a strongly typed language?
Because it was designed to be strongly typed. Generally, strongly typed is easier to work with for the compiler.

ahmed said:

why aren't destructors not used in java?
Huh?

ahmed said:

and what is the concept of unicode in char data type?
Unicode is an encoding format.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
chirag.jain18

chirag.jain18

    Newbie

  • Members
  • PipPip
  • 10 posts
1. why is java a strongly typed language?


If a language is not strongly typed, as javascript, time checking is delayed until runtime. But in strongly typed languages, type checking can be done at compile time, so less overhead at runtime.

It makes a good programming style to assign a value to its correct data type and easier to write a program and faster at runtime since type checking is performed at compile time only.

2. why aren't destructors not used in java?

there is no need for them because of garbage collection(GC). GC runs automatically when there are some unreferenced objects in memory. GC can be invoked by programmer explicitly but it is not a good idea to do so.


3. what is the concept of unicode in char data type?

Unicode is a standard data type and has more characters than ASCII. You can use characters of any language in your application if it supports unicode.
Since java supports unicode , it supports internationalization also. Use Google for more on unicode.