What are the advantages of passing this into a method instead of the current class object itself?



What are the advantages of passing this into a method instead of the current class object itself?..

Answer / Hemant Bhardwaj

Passing 'this' as an argument gives methods access to the instance variables and other non-static members of the class. It also allows for polymorphism since the method can be called with objects of different subclasses.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Which class contains a method: cloneable or object?

1 Answers  


Why we use set in java?

1 Answers  


Is arraylist sorted in java?

1 Answers  


What is the difference between access specifiers and access modifiers in java?

1 Answers  


we r taking <load-on-startup>0</load-on-startup> <load-on-startup>1</load-on-startup> in deployment descripter for loading servlets like serv1 N serv2? so 'll it take serv1 or serv2

2 Answers   CSC,


For ease of programming you can consider the maze as a 2D array with colors represented by below integer and characters (in capital letters). • B - Black • W -White • G- Green • R- Red R B W B W W W W W W B W B B W W W W W W W B W B W W W B W W W W B B W W W B W W W B W W B B B B W B W B W W B W W W B W W W B B B W W B W W W B W W B W B W W W B W B W W W W B B W W W W B W W W W W G Shortest Route Problem: • Solution that finds the shortest Route between Red and Green &#61607; White will have 1 Weight. &#61607; Red and Green carry no weights. &#61607; Shortest path is the path with less weight when you add up the weights in the path.

1 Answers  


What happens if we override private method?

1 Answers  


How do you remove duplicates from an array in java?

1 Answers  


Why are generics used?

1 Answers  


What are the different types of methodologies?

1 Answers  


is set interface synchronized by default???

2 Answers   Manhattan,


How can you eliminate duplicates?

2 Answers  


Categories