Avoiding base class tasks to run in derived class

Hi Everyone,

I have a doubt. Suppose there is base class which contain all the task and function definitions which are being used/called in child classes dervied from base class.But there would be some other tasks or function which would be called automatically as part of the flow in the task body of base class. If I dont’t want to run or call that function of base class, what can be done for the same?

class my_base extends uvm_test;
  `uvm_component_utils(base)

 function new(string name = "my_base" );
  super.new(name)
 endfunction

  virtual task body();
  
   //Task Definition_1
     task disp();
      $display("I am task 1" );
     endtask : disp  //Task Disp Ends here

   //Task Definition_2
     task zisp();
      $display("I am task 2" );
     endtask : zisp //Task Zisp Ends here
     
     junk_job();  
  endtask :body //Task body ends here

   task junk_job(); // Task junk definition
    $display("I am junk job");
   endtask : junk 

 endclass[\systemverilog]

// Derived Class
  class my_derived extends my_base();
     `uvm_component_utils(my_derived)
 
 function new(string name = "my_derived" );
  super.new(name)
 endfunction
 
  task body();
   super.body();
   task der();
    $display("I am called from Derived");
   endtask : der
  endtask : body

endclass

Now due to inheritence property all the tasks of body of base will be available and will run in derived class. I do not want to run junk_job() in my derived class. How this can be achieved?

 Thanks

In reply to kritikagoell:

The answer is in your question.
Notice how body is “virtual” and there is a call to super.body in the extended class’s body task?

If you were to make junk_job virtual, add the task to the extended class, and not do anything inside the task…