Back-End Programming Exam  >  Back-End Programming Videos  >  Java Programming Fundamentals: For Beginners  >  Java Programming Tutorial - 38 - Public; Private and this

Java Programming Tutorial - 38 - Public; Private and this Video Lecture | Java Programming Fundamentals: For Beginners - Back-End Programming

87 videos

FAQs on Java Programming Tutorial - 38 - Public; Private and this Video Lecture - Java Programming Fundamentals: For Beginners - Back-End Programming

1. What is the difference between public and private access modifiers in Java?
Ans. In Java, the public access modifier allows a class, method, or field to be accessed by any other class in any package. On the other hand, the private access modifier restricts the access to only within the same class. It prevents other classes from accessing or modifying the private member.
2. Can we use the private access modifier for a class in Java?
Ans. No, we cannot use the private access modifier for a class in Java. The private access modifier is not applicable to classes. It can only be used for methods and variables within a class.
3. What is the purpose of the 'this' keyword in Java?
Ans. The 'this' keyword in Java refers to the current instance of the class. It is mainly used to differentiate between instance variables and method parameters or local variables that have the same name. By using 'this', we can access the instance variables of the current class.
4. Can we access private members of a class using the 'this' keyword?
Ans. Yes, we can access private members of a class using the 'this' keyword. Since the 'this' keyword refers to the current instance of the class, it can be used to access and modify private variables or invoke private methods within the class.
5. Is it possible to access a public member of a class from outside the class?
Ans. Yes, it is possible to access a public member of a class from outside the class. The public access modifier allows the member to be accessed by any other class in any package. However, the class containing the public member must be imported or accessed using its fully qualified name.
87 videos
Explore Courses for Back-End Programming exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Previous Year Questions with Solutions

,

Free

,

Java Programming Tutorial - 38 - Public; Private and this Video Lecture | Java Programming Fundamentals: For Beginners - Back-End Programming

,

video lectures

,

Objective type Questions

,

Java Programming Tutorial - 38 - Public; Private and this Video Lecture | Java Programming Fundamentals: For Beginners - Back-End Programming

,

Sample Paper

,

pdf

,

ppt

,

Viva Questions

,

Extra Questions

,

Semester Notes

,

study material

,

Exam

,

mock tests for examination

,

shortcuts and tricks

,

practice quizzes

,

Java Programming Tutorial - 38 - Public; Private and this Video Lecture | Java Programming Fundamentals: For Beginners - Back-End Programming

,

MCQs

,

Important questions

,

Summary

,

past year papers

;