Java Tutorial menu

Java Quiz

Check what you have learned in this Java tutorial. Answer each question, then read the explanation.

How to Use This Quiz

  • Try to answer without looking back at the lessons
  • If you get one wrong, go back and read that chapter again
  • Write small programs to test anything you are not sure about

Quiz Questions

Exercise

Which file name must hold the class public class Shop?

Exercise

Which data type stores a decimal number like 99.5?

Exercise

What does System.out.println(9 / 2); print?

Exercise

How should you check whether two strings have the same text?

Exercise

What happens in a switch if you forget break after a case?

Exercise

How many times does this loop run? for (int i = 0; i < 5; i++)

Exercise

What is marks.length for int[] marks = {70, 80, 90};?

Exercise

Which method declaration returns a whole number?

Exercise

What is a constructor?

What Next?

Well done on finishing the Java tutorial. Keep practising by building small programs: a marks calculator, a shop bill or a simple bank account. To compare Java with a close cousin, look at the C# tutorial.

Learn Java with a teacher

Join the Python Programming course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp