function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RahulRahul 

If main class is private and inner class is public, can the inner class be accessible and vice-versa. I got this question in interview

Best Answer chosen by Rahul
Santosh Reddy MaddhuriSantosh Reddy Maddhuri
HI Sumit,

Main class must always be Public or global.

Private is the default access modifier Only for Inner classes

default class would be somethins like this
 
public/Global class MainClass{

  //do something.

 private Class InnerClass {
  
   //do something more.

 }


}


you can find detail info here

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_defining.htm


Hope this helps!

Regards,

Santosh.