+ Start a Discussion
Jyothsna ReddyJyothsna Reddy 

Superclass in apex?

Hello,
What is the SuperClass in apex ? In Java Object is super class.
one way of intializing/decalring an object is below
Object obj ;
public className(){
obj =new Sample();
}
other way is Sample sampObj=new Sample();

Now ,Comming to salesforce ,How can i declare the Object.
I know one way is Sample__c obj=new Sample__c();
I want to use super class while initializing.... 



Best Answer chosen by Jyothsna Reddy
bob_buzzardbob_buzzard
All custom and standard objects inherit from the sobject superclass, so you can do the following:

Sobject obj;

obj=new Sample__c();


All Answers

bob_buzzardbob_buzzard
All custom and standard objects inherit from the sobject superclass, so you can do the following:

Sobject obj;

obj=new Sample__c();


This was selected as the best answer
Jyothsna ReddyJyothsna Reddy
Thanq, can I   pass object dynamically...
Means I have String s="Sample__c";

Sobject obj;
String s="Sample__c";
obj= new s();
Actually this String s will come dynamically ...Is this possible?

bob_buzzardbob_buzzard
No - String is a primitive in Apex so doesn't have the concept of a superclass.