+ Start a Discussion
NandhuNandhu 

Create an apex for the student like name, I’d, date of birth and how to fetch the record using constructor and method order

Best Answer chosen by Nandhu
Deepali KulshresthaDeepali Kulshrestha
Hi Nandhini,

I have gone through your problem please refer bellow code:- 
public class Testabc {
     String  name;
    integer  id;
    public Testabc(){
       name = 'xyz';
       id= 101;
       System.debug('Inside Constructor');
    }
    public void display(){
      System.debug('Name is =' +name);
      System.debug('Id is= '+id);
    }
}


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com

All Answers

Danish HodaDanish Hoda
Hi Nandhini,

You can refer below code :
public class testClass{

    public student__c testClass(String id){
        return [SELECT Id, Name, DOB__C from student__c WHERE Id =:id];
    }
}

 
Deepali KulshresthaDeepali Kulshrestha
Hi Nandhini,

I have gone through your problem please refer bellow code:- 
public class Testabc {
     String  name;
    integer  id;
    public Testabc(){
       name = 'xyz';
       id= 101;
       System.debug('Inside Constructor');
    }
    public void display(){
      System.debug('Name is =' +name);
      System.debug('Id is= '+id);
    }
}


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
This was selected as the best answer