JP Morgan Interview Question for Java Developers


Country: India
Interview Type: Written Test




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

The output is :

5
Sub

Instance variables CANNOT be overridden in Java. In Java only methods can be overridden.

When you declare a field with the same name as an existing field in a superclass, the new field hides the existing field. The existing field from the superclass is still present in the subclass, and can even be used ... subject to the normal Java access rules.

- Flash May 14, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

5 sub.

variable belongs to reference and method belongs to objects.

- AmiK May 14, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

5 Sub

variable belongs to reference and methods belongs to object.

- amitgupta123456 May 14, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ANS: 5 and SUB because overriding only method label not a variable label So call ref not a object.

- RajatRajVarshney May 20, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

5 sub

- Somendra Raj June 21, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2
Sub

- Anonymous March 30, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Answer is 5 and 2

- Himanshu Jain June 07, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

First it will print 5 and then 2

- Himanshu Jain June 07, 2018 | 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