The nuclear modification factor RAA and the azimuthal anisotropy coefficient v2 of prompt and nonprompt (i.e. those from decays of b hadrons) J / ψ mesons, measured from PbPb and pp collisions at sNN=2.76TeV at the LHC, are reported. The results are presented in several event centrality intervals and several kinematic regions, for transverse momenta pT> 6.5 GeV/c and rapidity | y| < 2.4 , extending down to pT= 3 GeV/c in the 1.6 < | y| < 2.4 range. The v2 of prompt J / ψ is found to be nonzero, but with no strong dependence on centrality, rapidity, or pT over the full kinematic range studied. The measured v2 of nonprompt J / ψ is consistent with zero. The RAA of prompt J / ψ exhibits a suppression that increases from peripheral to central collisions but does not vary strongly as a function of either y or pT in the fiducial range. The nonprompt J / ψRAA shows a suppression which becomes stronger as rapidity or pT increases. The v2 and RAA of open and hidden charm, and of open charm and beauty, are compared.