OAKLAND, Calif. (AP) _ Two teen-age boys who allegedly confessed to killing a bus driver in a vengeful shooting had planned to hijack the vehicle and execute the passengers, police said.

The boys, arrested Sunday night, were booked for investigation of murder and remained in custody at a juvenile detention center. They faced arraignment later today in the slaying of AC Transit driver Billy ''B.J.'' Givens.

Givens, 43, died Thursday shortly after being shot at point-blank range with a .22-caliber rifle. Three passengers suffered gunshot wounds.

The suspects, 15 and 17, told police they wanted to avenge a traffic accident that killed their friends' mother, Ellen Palmer, police Lt. Jim Hahn said.

''They had several meetings to plan their attack. They were going to board the bus, force the driver to a remote area and execute him and any passengers that might be witnesses,'' Hahn said. ''If the first bus was too crowded, they would wait for (another).''

But the two scrapped the plan at the last minute for an unknown reason, Hahn said, when they boarded a bus with 20 people on it. After the 17-year-old shouted obscenities at Givens, the driver asked ''What's wrong?'' and was shot several times, police said.

The day before, Mrs. Palmer, 52, was killed in a collision with an AC Transit bus. Givens was not the driver, and the fatal accident did not occur on his line, Hahn said.

''In their interviews with investigators, the juveniles gave the sole motive for the murder as a retaliation against AC Transit for what they perceived as the wrongful death of their friends' mother,'' Hahn said.

The older youth escaped six or seven months ago from a detention center in San Leandro, where he had been sent in connection with drug charges, Hahn said. A warrant had been filed for the younger boy, who failed to appear in juvenile court recently on a burglary charge, police said.

Witnesses said four young men had stepped aboard Givens' vehicle, but Hahn said Monday that only two youths actually got on the bus. A third youth was a friend who followed the suspects in a vain attempt to dissuade them from carrying out their plan, and the fourth probably was a passer-by, he said.