can two class in a code be public??if yes then how??

Answers were Sorted based on User's Feedback



can two class in a code be public??if yes then how??..

Answer / sreejesh1987

One java source file must have only one top-level(top level means not an inner class) public class with the same name as the name of the source file .


You can have inner classes to a class which are public. Hence in this way it is possible to have more than one public class in a single file.

Is This Answer Correct ?    11 Yes 2 No

can two class in a code be public??if yes then how??..

Answer / siva

NO only one class should be public if we write multiple
classes in a same file.we can write multiple class files in
a single file.if main() is there in one of the classes then
it should be declare as public.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the equal sign?

0 Answers  


What are the string methods in java?

0 Answers  


Can an abstract class have a constructor?

1 Answers   RBS, Wipro,


How many bytes is a url?

0 Answers  


Is object a data type?

0 Answers  


What is natural ordering in java?

0 Answers  


Write a program to check string is palindrome without using loop?

0 Answers   Cyient,


Difference in the use of print, println, and printf.

5 Answers  


What causes memory leaks in java?

0 Answers  


what is mean by ooad? where we are using? can you tell me any real time example?

1 Answers   Eka Software,


Write a method to check if input string is palindrome?

0 Answers  


EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.

1 Answers   EDS,


Categories