Java2 eg
Upcoming SlideShare
Loading in...5
×
 

Java2 eg

on

  • 537 views

 

Statistics

Views

Total Views
537
Views on SlideShare
537
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Java program is actually a collection of files distributed in a forest of tree-structured directory hierarchy. The roots are accessible thro CLASSPATH, and the directory names are package names. The file names correspond to PUBLIC classes. Java system uses this mapping to fetch classes from the file system.
  • PUBLIC by default. A class implementing this interface must explicitly declare methods as PUBLIC because the default is PACKAGE. ( cut-and-paste of headers will not work!)
  • Need Wrapper class Integer to convert primitive value of int type to a reference type value. Implementing means adding data structure and defining methods in terms of primitive operations on the data structures. Both key and value must be non- null .
  • Framework-oriented Programming
  • Array object contains size info, array type does not. Cf. Array bounds can be checked at run-time. Empty array : new int[0][0];
  • intArray -> 0 2 4 6 8
  • argv = args argc = args.length Complete Java Application
  • Length field: objects carry type tags array objects carry bound information index : 0.. Length - 1 23 args “ c” “ a” “ abc”
  • In Java, strings are treated as objects that can be manipulated using well-defined operations on strings. In C++, strings are basically a sequence of characters followed by a null-character. One can perform low-level operations based on the implementation detail that can effect/change the string-view. For instance, consider a string variable char * str containing a pointer to the sequence of bytes abcde Now one can assign to position 2 and obtain a string ab. So, replacement of a charater actually manifests itself as deletion of suffix.
  • “ +”(addition) is associative wrt Integers and Reals. “ +” (concatenation) is associative wrt strings. However, when we combine the two in an expression ordering becomes important because of how the overloading is resolved. Concatenation freshly allocates a string and initializes it by copying the contents of the operand strings.
  • All constant string expressions are evaluated at compile-time, and equivalent expressions are mapped to the same string object. Explicit invocation of “intern()” accomplishes the same task at run-rime.
  • In dynamic typing, the operations perform type checking followed by traditional expression evaluation.
  • Except for the case of an expression containing a type cast, static typing is supposed to guarantee that a method call on a (polymorphic) variable will succeed by ensuring existence of the method for all objects that the variable can hold reference to.

Java2 eg Java2 eg Presentation Transcript