GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Mar-2008, 20:41
Blase Blase is offline
Junior Member
 
Join Date: Jun 2006
Posts: 36
Blase has a little shameless behaviour in the past

JAVA questions I encountered during an interview


Hi,

These are questions I encountered during an interview. With my introductory background, I had no idea what got into them. Could someone tell me where I should start my search for the answers? Appreciate your hints.

Write a function in that integrates a globally given function f?
What is the danger of using public unsigned integers within a class?
In a diamond-shaped inheritance hierarchy, how to ensure that only 1 copy of parent is created?

Thanks in advance
  #2  
Old 29-Mar-2008, 19:58
TurboPT's Avatar
TurboPT TurboPT is online now
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 926
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: JAVA questions I encountered during an interview


Quote:
Originally Posted by Blase
Write a function in that integrates a globally given function f?
Not sure what you're asking here. Just create a function to call another public function?

Quote:
Originally Posted by Blase
What is the danger of using public unsigned integers within a class?
Two things:
1. Java doesn't know 'unsigned ints', which is discussed here.
2. Web services and XSD can be problematic with Java:
Quote:
Some features of XSD schema cannot be represented well in
some current platforms. One example is the unsigned inte-
ger types in XSD. Although .NET provides unsigned types,
Java does not. Therefore using unsigned integers types
within interoperable Web services is not recommended
That snippet was found here. (search the PDF to find it)

Quote:
Originally Posted by Blase
In a diamond-shaped inheritance hierarchy, how to ensure that only 1 copy of parent is created?
I'm still pondering this one, but I think it has to do with 'final' classing, but I'm not 100% certain.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 25-Apr-2008, 13:36
JustinFox JustinFox is offline
Junior Member
 
Join Date: Mar 2008
Posts: 59
JustinFox will become famous soon enough

Re: JAVA questions I encountered during an interview


In java programming (or for any languange for that matter), a "diamond-style hierarchy" is a very bad programming technique.

For one, you can't extend from two classes anyways. if you have multiple class that use similar methods, just use an interface.

Diamond-style hierarchy is known as the "diamond of death".

Justin Fox
  #4  
Old 28-Apr-2008, 11:44
JustinFox JustinFox is offline
Junior Member
 
Join Date: Mar 2008
Posts: 59
JustinFox will become famous soon enough

Re: JAVA questions I encountered during an interview


but if you wanted to know how many copies of a class is made, or restrict them, you would just have a static int and just increment that int on each init() of the object.

JAVA Code:

public class A 
{

   static int copies = 0;

   public static getCopies(){
   return copies;
   }

   public A{
   copies += 1;
   }

   public static void main (String[]args)
   {

      int i = 0;

      while ( i < 9)
      {  

       if(A.getCopies > 2)
       System.out.println("Out of memory");
       else{
       A my1A = new A();
       System.out.println("Memory Allocated");

       i ++;
       }

       }

   }

}


Justin Fox
 
 

Recent GIDBlogNARMY by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With Recursive Functions jonas12rena C Programming Language 1 31-Jul-2006 11:12
Clueless about video cards, help please ChicagoBearsFan Computer Hardware Forum 8 10-Apr-2006 09:49

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:38.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.