Bloomberg LP Interview Question for Software Engineer / Developers






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

Non static variables cannot be accessed from static methods because static methods are class specific and are not linked to any specific instance of the class, static methods can be invoked even before we create any instance of the class i.e. even before a non-static or instance variable is created and available we can invoke static.

- mk April 10, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

i think the question is
Why is access to non-static variables not allowed from static methods in java?

because access to static variables is allowed from non-static methods in java

- sarty July 22, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Because non-static variables are object level variable, which is not permitted to change by a class method. But static variable, is also part of the object as well.

- Ranjan, November 22, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Java follows "declaration before read" rule. static variables are always declared before any member method could call it because they are class level. Isnt that quite logical to remember rather than remembering the rules under quotes? :)

- CuriousCrab June 21, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Either its a trick question or you got the wordings wrong

- anon September 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

both @ anon
any smart answers !

- non-anonymous October 02, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

According to concepts static variables can be accessed in non-static methods but the reverse is not true.
The static variables are common to class i.e. the same copy of the static data will be available for all the instance of that class.

- Pranav Suresh Shah November 22, 2009 | Flag


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