Citrix System Inc Interview Question for Software Engineer / Developers


Team: Shared file
Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
3
of 3 vote

My interpretation of question is that instead of handling the exception after catching it, what happens when we re-throw t again.... The answer for that it will go up the method call hierarchy and be eventually handled by JVM (you will stack trace once it reaches at that point)

- ??? January 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

When an exception occurs and if re-throwing the same exception, then stackTrace would be still maintained. Unless we create a new exception object, the stack trace of the exception from callee method still preserves.

public class RethrowException {
	
	void method1() throws Exception{
		throw new Exception("exception message");
	}
	
	void method2() throws Exception{
		try{
			method1();
		}catch(Exception exception){
			throw exception;
		}
	}
	
	public static void main(String[] args) throws Exception{
		RethrowException re = new RethrowException();
		re.method2();
	}
}

- harry November 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Question is very vague... It actually depends on the way you are re-throwing the exception. If you re-throw the caught exception as a inner exception parameter to constructor of new exception, original stack trace is maintained. (Note:Not all exception constructors support inner exceptions). But if you create new exception and re throw new exception, the original caught exception's stack trace is lost.

This is what I know...

- <--> January 15, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It will be handled by the appropriate catch handler defined in that block where we are re throwing it.

- Anonymous January 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Somitime to wrap the exception rethrowing of exception is uesd

- sanjay nitwal January 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Example : we have DAO in that one method accesses database and can throw SQLEXcetion & another method reads a file can throw FileNotFoundException & another method uses WebServices can throw RemoteException .If in there try catch block we rethrow a generalized exception with correct message then the method interacting with the DAO method's need not to handle different type of exceptions once handling of wraped generalized exception will be enough

- sanjay nitwal January 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Exception will be triggered where it is finally handled, with the stack trace containing information about every time it was thrown/raised

- shashankshakehar March 20, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More