This is my code:
 public class Init{
    public static WebDriver driver;
    @BeforeSuite
    public static void init_method1(){
        System.setProperty("webdriver.ie.driver", "//Provide IEDriverLocation//");
        driver = new InternetExplorerDriver();  
    }
}
public class B{
    @FindBy(xpath="XXXXxxxxxx")
    WebElement b_obj;
    public B(){
        PageFactory.initElements(Init.driver, this);
    }   
    public void b_method1(){
        b_obj.sendkeys();
    }
}
public class C{
    B b =  new B();
    @Test
    public void c_method1(){
        b.b_method1;
        }
}
In TestNG.xml,
<class name= "Package1.Init"></class>
<class name= "Package1.C"></class>
Error:
java.lang.NullPointerException at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69) at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38) at com.sun.proxy.$Proxy9.isDisplayed(Unknown Source) at org.openqa.selenium.support.ui.ExpectedConditions.elementIfVisible(ExpectedConditions.java:302) at org.openqa.selenium.support.ui.ExpectedConditions.access$100(ExpectedConditions.java:41) at org.openqa.selenium.support.ui.ExpectedConditions$10.apply(ExpectedConditions.java:288) at org.openqa.selenium.support.ui.ExpectedConditions$10.apply(ExpectedConditions.java:285) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:238) at Package1.B.b_method1(B.java:8) at Package1.C.c_method1(C.java:3) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) at org.testng.TestRunner.privateRun(TestRunner.java:756) at org.testng.TestRunner.run(TestRunner.java:610) at org.testng.SuiteRunner.runTest(SuiteRunner.java:387) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) at org.testng.SuiteRunner.run(SuiteRunner.java:289) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) at org.testng.TestNG.runSuites(TestNG.java:1133) at org.testng.TestNG.run(TestNG.java:1104) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
 
    