Here you should not be seeing the efficiency as both will be equally efficient. But rather than doing this you should think about the future extensibility of the class.
In that matter I think method B would be good as you can change the parser so some other one in future.
class DataRetriever{
private DataParser dataParser;
public DataRetriever(){
dataParser = new JsonDataParser(); //tomorrow this can be changed to something else
}
public DataObject getData(String data){
// Get data from server using URL
return dataParser.parseData(data);
}
}
UPDATE: If you are looking for a proper OOP solution for this, then you should go with factory pattern which will return you the instance of the parser based on the type you provide it.
class ParserFactory{
//get parser
public DataParser createParser(int type){
//creates the new parser based on type and returns it
}
}
this would be better as the creation of the parser would be the responsibility of the factory and that would make more sense IMO.
Link for Factory Pattern