Java Programming Fundamentals

Test your knowledge of Java programming language concepts including interfaces, abstract classes, exceptions, method overriding, and Hungarian notation.

20 Questions Published

Questions

Question 1 True/False

Overridden method is in child class and Overriding method is in parent class.

  1. True
  2. False
Question 2 True/False

we cannot override a non-abstract method as abstract.

  1. True
  2. False
Question 3 True/False

class P { public void doIt() {} } class C extends P { private void doIt() {}} It is not legal.

  1. True
  2. False
Question 4 Multiple Choice (Single Answer)

Java is a

  1. Iterpreted Language
  2. Compiled Language
  3. Byte Code Language
  4. None of these
Question 5 Multiple Choice (Multiple Answers)

The main method has to be "public static" because of the following reasons. (Two options)

  1. static because it has to be constant and cannot be changed.
  2. static because it has to be loaded by the JVM without instantiating it
  3. public because other classes may also call the main method of a class
  4. public because JVM has to have access to the main method in order to call it.
Question 6 Multiple Choice (Multiple Answers)

Which of the following are valid main method declarations?

  1. static public void main(String []args)
  2. public static void main(String heyhey[])
  3. public static int main(String[] args)
  4. public static void main(String ...args)
  5. public static void main (String [], int argv)
Question 7 Multiple Choice (Single Answer)

Checked Exceptions are

  1. all sub-classes of Throwable
  2. not the sub classes of RuntimeException
  3. all sub-classes of Error
  4. None of these
Question 8 Multiple Choice (Single Answer)

int i=5; int a = + --i/2.0;

  1. Does not compile saying binary operator has invalid use
  2. 2.0
  3. 2.5
  4. exception will be thrown
Question 9 Multiple Choice (Single Answer)

Consider the following declarations ... float f = 4.5; //1 double d = 9.22; //2 short s = 3; //3 char c = s; //4 Which lines will throw error if any?

  1. 1 and 4
  2. 1
  3. 2 and 3
  4. 3 and 4
  5. no error
Question 10 Multiple Choice (Single Answer)

What gets printed here... System.out.println("Sum of 5 and 3 is:"+5+3);

  1. Sum of 5 and 3 is:8
  2. error during compilation
  3. Sum of 5 and 3 is:53
  4. None of these
Question 11 True/False

Based on the description above, we could say that the variable name "lAccountNum" follows the Systems Hungarian Notation.

  1. True
  2. False
Question 12 Multiple Choice (Single Answer)

Based on Simonyi's convention, the notation "w" implies:

  1. a byte
  2. a word
  3. a boolean
  4. a null-terminated string
Question 13 Multiple Choice (Single Answer)

"fBusy" represents a variable of the following data type:

  1. floating-point
  2. double
  3. boolean
  4. function
Question 14 Multiple Choice (Single Answer)

Given the above scenario, the variable name "aulColors" represents:

  1. an array of unsigned long
  2. an array of floating-point values
  3. an array of unary
  4. an array of zero-terminated strings
Question 15 True/False

The variable "g_nWheels" follows the Hungarian notation.

  1. True
  2. False
Question 16 Multiple Choice (Single Answer)

All variables in an Interface are by default __________.

  1. public
  2. final
  3. static
  4. all the above
  5. there should not be any variable in an interface
Question 17 True/False

An Interface can only have public members whereas an abstract class can contain private as well as protected members

  1. True
  2. False
Question 18 True/False

Abstract class's can have a constructor.

  1. True
  2. False
Question 19 Multiple Choice (Single Answer)

which of these is false?

  1. a class implements one or more interfaces
  2. a class extends one or more interfaces
  3. an interface extends one of more interfaces
  4. Serializable is a marker Interface
Question 20 True/False

The following interface is valid. public interface Marker { }

  1. True
  2. False