100+ Important Core Java Interview Questions and Answers 21 to 30

VTU Update 9-3-2021 | Reopening of Even Semester 

Step by Step Procedure to apply for a scholarship in State Scholarship Portal – SSP – 2021

Step 1: How to create an account in State Scholarship Portal SSP 2021

Step 2: Upload documents in SSP portal for e-Attestation

Step 3: Log in to your account and apply for the scholarship

List of documents to be uploaded in e-attestation portal

Subscribe to Youtube and Telegram Channel for Regular Updates

 
Video Tutorials
Python for Beginners Video tutorial
Big Data Analytics Video Tutorial Placement Video Tutorial

Core Java Interview Questions and Answers: Question 21 to Question 30

Here you can find the most important top) core java interview questions and answers (21 to 30) for placement (campus) interview and competitive examinations.

READ  100+ Important Core Java Interview Questions and Answers 51 to 70

21. Does the order of public and static declaration matter in the main() method?

Answer: No. It doesn’t matter but void should always come before main().

22. Can a source file contain more than one class declaration?

Answer: Yes a single source file can contain any number of Class declarations but only one of the class can be declared as public.

23. What is a package?

Answer: Package is a collection of related classes and interfaces. package declaration should be the first statement in a java class.

24. Which package is imported by default?

Answer: java.lang package is imported by default even without a package declaration.

25. Can a class declared as private be accessed outside its package?

Answer: Not possible.

26. Can a class be declared as protected?

Answer: The protected access modifier cannot be applied to class and interfaces. Methods, fields can be declared protected, however, methods and fields in an interface cannot be declared protected.

READ  Python Interview Questions Part 4

27. What is the access scope of a protected method?

Answer: A protected method can be accessed by the classes within the same package or by the subclasses of the class in any package.

28. What is the purpose of declaring a variable as final?

Answer: A final variable’s value can’t be changed. final variables should be initialized before using them.

29. What is the impact of declaring a method as final?

Answer: A method declared as final can’t be overridden. A sub-class can’t have the same method signature with a different implementation.

30. I don’t want my class to be inherited by any other class. What should i do?

READ  17EE73 - High Voltage Engineering – HVE VTU Notes

Answer: You should declare your class as final. But you can’t define your class as final if it is an abstract class. A class declared as final can’t be extended by any other class.

Summary

Here you can find the frequently asked Core Java Interview Questions and Answers 21 to 30. If you like the material share it with your friends. Like the Facebook page for regular updates and YouTube channel for video tutorials.

Python Sample Programs for Placement Preparation

Leave a Comment

Your email address will not be published. Required fields are marked *