Marlon Churchill wrote:This question is about how Java creates objects and when. I think I'm missing some basic concept. the code and question are from the Sierra and Bates SCJP 6 book, Chapter 3, question 11.
Given
When line 16 is reached, how many objects are available for garbage collection?
The correct answer is 1, but I seem to count 3. b1, b2, and a1.
Backing up a bit, how many objects were created? I'm not really sure.
Is it seven? a1, a1.b1, a1.b2, b1, b1, a2, and a2.b2 ? Since Alpha.b1 is static, I think there is no separate a2.b1 object, the static Beta b1 belongs to the class Alpha.
or is it four? a1, b1, b2 and a2. The variables in the Alpha class are reference variables, not objects.
still, setting b1 and b2 both equal to null, seems to make them eligible for GC.
Does setting a2.b2 = b2 mean the code can still reach b2, so b2 (although null) is not eligible for GC?
Originally posted by Ron Yorrick:
When I test the program with the file already open in notepad, the program is still able to get a lock on the file even though I expect it not to be able to.
Originally posted by Joseph Kampf:
You are using FileOutputStream directly?
I suggest that you try passing your FileOutputStream into the constructor of a BufferedOutputStream, then write to the BufferedOutputStream.
Joe
Originally posted by Jay Damon:
I know I should probably be using a logging mechanism but bear with me (baby steps please).
I am working on a web application that logs page accesses to a mapped Windows drive. This has become somewhat of a bottleneck in the application. My first approach was to spin the logging process off as a thread. However, I have discovered that doing so is still somewhat expensive.
However, I have discovered that by hanging onto the reference to the OutputStream/Writer object and invoking flush() after the write, I can increase performance by a factor of 10 or more. This concerns me though because the object will never be explicitly closed.
The PageLogger class I have written for testing purposes invokes close() in its overridden finalize() method but I'm concerned that is not sufficient.
Is this a reason for concern or is there perhaps some other option I am overlooking?
Originally posted by Reddy Anoop:
Hello,
I need help/suggestion on how to resolve the following issue.
I need to read an xml file stored in as BLOB in an oracle table. I am able to read the file. I am stuck after this because, I am calling another java program to parse by passing in an XML file. Since I am not sure how to convert the BLOB to an xml file, I am getting no where. Any suggestions/help is greatly appreciated.
Here is what I need to do.
1. Read BLOB data type from xml
2. Convert the BLOB into an xml file and call the parser program with this
xml file as the parameter.
Regards
Anoop
Originally posted by xiao sean:
hi guys,
i need a help on this assignment. the question is to require me to print a letter X onto screen using *.
but no matter how i try, the o/p is
**^^^
**^^^
***^^
**^*^
**^^*
any advice please?
-------------
/**
* Write a description of class ForEg3 here.
*
* @author (your name)
* @version (a version number or a date)
*/
class ForEg3
{
public static void main (String[]args)
{
for (int row=1; row <=5; row++)
{
for (int col=1; col <=5; col++)
if (row==col || (col <= (5-col)) )
System.out.print("*");
else System.out.print("^");
System.out.println();
}
}
}
---------
Originally posted by Tom Griffith:
Hello. If somebody has a minute, I seem to be going in crocles on this one. I have a hashmap (referenced as data_map) that i am serializing, however, when I load test it, i run out of java heap space...
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(data_map);
i've been trying to go about maybe chunking the hashmap into the ObjectOutputStream but it all comes back to the inability to read/write the object as is to any stream (to convert it to bytes). I appreciate any help and input. Thank you.
[ August 22, 2007: Message edited by: Tom Griffith ]
Originally posted by Senthil Kumar SS:
In our application we bind an HashMap to the InitialContext. My doubt is will this be replicated to the available managed servers when the current managed server goes down.
Originally posted by yathamshetti ramchander:
hai
this is program is compiling and running but nothing is displayed
i created separate Domain as ramchander
and usename is : ramchander
pwd : rampassword
i configured weblogic
http://localhost:7001/console/login/LoginForm.jsp
import javax.naming.*;
import java.rmi.*;
import java.util.*;
public class UseJndi{
public static void main(String args[]){
try{
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
h.put(Context.SECURITY_PRINCIPAL, "ramchander");//userName
h.put(Context.SECURITY_CREDENTIALS, "rampassword");//password
Context ic = new InitialContext(h);
System.out.println(" initial context = "+ ic);
NamingEnumeration ne = ic.listBindings("");
while (ne.hasMore()) {
Binding b = (Binding)ne.next();
System.out.println( b.getName());
System.out.println(b.getObject());
}
}catch (Exception e){}
}
}
i compiled
javac UseJndi.java
java UseJndi
no answer...
> tell me where to keep above file UseJndi.java
> give me steps to execute the above program.....
Originally posted by thomas jacob:
Can a production application run on the administration server?. Please confirm whether production application can only run on managed servers and not admin server of weblogic.
Originally posted by Tony Smith:
I think B is also an object, by definition all object has default constructor. Check out my following test code, it run just fine...
}
Originally posted by Ransika deSilva:
Hi all,
I want to develop an application which gets 3000 Asynchronous requests per second and I would be very glad to hear your expert ideas on this? This application is intended for the Wireless market. So far I have done some research on Mobicent application and sounds promising. But I am not very clear on this particular point; if a thread is created to handle an incoming request, we need to create 3000 threads per a second, which I am sure not very good. So what are the frameworks which I can do the research on. Thanks and regards.