nerdexam
Android

OA0-002 · Question #68

Which of these is the correct code to create a Bitmap object using the file res/drawable/image.png?

The correct answer is B. Bitmap img = BitmapFactory.decodeResource(R.drawable.image). See the full explanation below for the reasoning.

Question

Which of these is the correct code to create a Bitmap object using the file res/drawable/image.png?

Options

  • ABitmap img = BitmapFactory.decodeFile(R.drawable.image),
  • BBitmap img = BitmapFactory.decodeResource(R.drawable.image);
  • CBitmap img = new Bitmap(R.drawable.image);
  • DBitmap img = (Bitmap)GraphicsFactory.decodeResouces(R.drawable.image);

How the community answered

(42 responses)
  • A
    2% (1)
  • B
    86% (36)
  • C
    7% (3)
  • D
    5% (2)

Community Discussion

No community discussion yet for this question.

Full OA0-002 Practice