Java Programming MCQs

15 practice MCQs on this page Page 2 of 2

Tap an option to check your answer — the correct answer and full explanation appear after you choose.

ProgrammingJava Programming PPSC FPSC NTSID: PROG-099

In Java, what is a 'class'?

  1. AA plan or template from which objects are made. ✓ Correct answer
  2. BA single number stored in memory.
  3. CA command that prints text on the screen.
  4. DA file that stores only pictures.
ProgrammingJava Programming PPSC FPSC NTSID: PROG-104

In Java, which data type is used to store whole numbers?

  1. AString
  2. Bdouble
  3. Cint ✓ Correct answer
  4. Dboolean
ProgrammingJava Programming PPSC FPSC NTSID: PROG-109

In Java, which mark is placed at the end of a simple statement, for example after int age = 20?

  1. AA comma.
  2. BA full stop.
  3. CA semicolon. ✓ Correct answer
  4. DA colon.
ProgrammingJava Programming PPSC FPSC NTSID: PROG-114

In Java, which keyword is used by a class to inherit from another class?

  1. Aimplements
  2. Bextends ✓ Correct answer
  3. Cinherits
  4. Dsuper
ProgrammingJava Programming PPSC FPSC NTSID: PROG-119

In Java, what is a 'variable'?

  1. AA place in memory that stores a value. ✓ Correct answer
  2. BA fixed number that never changes.
  3. CA command that stops a program.
  4. DA picture shown on the screen.
ProgrammingJava Programming BPSCID: BPP-2786

In Java, the entry point of a program is the method:

  1. Amain ✓ Correct answer
  2. Brun
  3. Cstart
  4. Dinit
ProgrammingJava Programming FPSCID: FPP-11404

Which of the following is a feature of object-oriented programming?

  1. AMacros
  2. BInheritance ✓ Correct answer
  3. CPointers only
  4. DGoto statement
ProgrammingJava Programming PPSCID: LTP-7700

The Java programming language was created by:

  1. AJames Gosling ✓ Correct answer
  2. BGuido van Rossum
  3. CDennis Ritchie
  4. DBjarne Stroustrup
ProgrammingJava Programming PPSCID: LTP-7701

In Java, the JVM is responsible for:

  1. APrinting documents
  2. BExecuting Java bytecode ✓ Correct answer
  3. CDesigning web pages
  4. DStoring passwords
ProgrammingJava Programming PPSCID: LTP-7702

Java is famous for the principle known as:

  1. AWrite once, print anywhere
  2. BRun once, forget it
  3. CWrite once, run anywhere ✓ Correct answer
  4. DCompile once, delete it
ProgrammingJava Programming PPSCID: LTP-7703

In Java, which access modifier makes a member visible only inside its own class?

  1. Apublic
  2. Bprotected
  3. Cstatic
  4. Dprivate ✓ Correct answer
ProgrammingJava Programming PPSCID: LTP-7704

In Java, inheritance between classes is created with which keyword?

  1. Aextends ✓ Correct answer
  2. Binherits
  3. Cimplements
  4. Dderives
ProgrammingJava Programming PPSCID: LTP-7705

In a Java program, execution begins in which method?

  1. Astart
  2. Bmain ✓ Correct answer
  3. Cinit
  4. Drun
ProgrammingJava Programming PPSCID: LTP-7706

Which of the following is the correct signature of the main method in Java?

  1. Apublic void main()
  2. Bstatic int main()
  3. Cpublic static void main(String[] args) ✓ Correct answer
  4. Dvoid start(String args)
ProgrammingJava Programming PPSCID: LTP-7707

Encapsulation in Java means:

  1. ADeleting all private data
  2. BWriting code without classes
  3. CPrinting data to the screen
  4. DBundling data and methods together inside a class ✓ Correct answer

Practice these MCQs interactively