Programming Languages Fundamentals Quiz

A quiz covering fundamental concepts in multiple programming languages including Java, C#, and Visual Basic. Tests knowledge of data types, operators, keywords, compilation rules, and language-specific features.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of these is used to open an database?

  1. Set dbMyDB = OpenDatabase
  2. Set dbMyDB = OpenDatabase("MyDatabase.mdb")
  3. dbMyDB = OpenDatabase("MyDatabase.mdb")
  4. None of these
Question 2 Multiple Choice (Single Answer)

On start up, which of these window is not displayed?

  1. The Class window
  2. The Project window
  3. The Properties window
  4. The Blank Form window
Question 3 Multiple Choice (Single Answer)

Which of these is not an collection of the VB project?

  1. The object module
  2. The class module
  3. The form module
  4. The global module
Question 4 Multiple Choice (Single Answer)

Visual Basic uses an object called ______ to hold your table?

  1. file
  2. Record
  3. table
  4. RecordSet
Question 5 Multiple Choice (Single Answer)

What will be printed out if this code is run with the following command line? java myprog good morning public class myprog{ public static void main(String argv[]) { System.out.println(argv[2]); } }

  1. myprog
  2. good
  3. morning
  4. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"
Question 6 Multiple Choice (Single Answer)

A byte can be of what size

  1. -128 to 127
  2. (-2 power 8 )-1 to 2 power 8
  3. -255 to 256
  4. depends on the particular implementation of the Java Virtual machine
Question 7 Multiple Choice (Single Answer)

What data will be printed out if you attempt to compile and run the following code(ignore newline in output)? int i=1; switch (i) { case 0: System.out.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); default: System.out.println("default"); }

  1. one
  2. one default
  3. one two default
  4. default
Question 8 Multiple Choice (Single Answer)

Which of the following will output -4.0

  1. System.out.println(Math.floor(-4.7));
  2. System.out.println(Math.round(-4.7));
  3. System.out.println(Math.ceil(-4.7));
  4. System.out.println(Math.min(-4.7));
Question 9 Multiple Choice (Single Answer)

What is the result of the following operation? System.out.println(4 | 3);

  1. 6
  2. 0
  3. 1
  4. 7
Question 10 Multiple Choice (Single Answer)

Which of the following lines will compile without warning or error.

  1. float f=2.3;
  2. char c="z";
  3. boolean b=null;
  4. int i=21;
  5. byte b=257;
Question 11 Multiple Choice (Single Answer)

Which of the following will throw an error while compilation 1) import java.awt.; package Mypackage; class Myclass {} 2) package MyPackage; import java.awt.; class MyClass{} 3) /*This is a comment / package MyPackage; import java.awt.; class MyClass{}

  1. Option 1
  2. Option 2
  3. Option 1 & 2
  4. Option 3
  5. Option 2 & 3
Question 12 Multiple Choice (Single Answer)

What will happen if you try to compile and run the following code public class MyClass { public static void main(String arguments[]) { amethod(arguments); } public void amethod(String[] arguments) { System.out.println(arguments); System.out.println(arguments[1]); } }

  1. error method main not correct
  2. error Can't make static reference to void a method.
  3. error array must include parameter
  4. a method must be declared with String
Question 13 Multiple Choice (Single Answer)

If you wanted to find out where the position of the letter v (ie return 2) in the string s containing "Java", which of the following could you use?

  1. mid(2,s);
  2. charAt(2);
  3. s.indexOf('v');
  4. indexOf(s,'v');
Question 14 Multiple Choice (Single Answer)

Which of the following is not a keyword or reserved word in Java?

  1. if
  2. then
  3. goto
  4. while
  5. case
Question 15 Multiple Choice (Single Answer)

if(check4Biz(storeNum) != null) {} Referring to the above, what datatype could be returned by method check4Biz()?

  1. Boolean
  2. int
  3. char
  4. float
Question 16 Multiple Choice (Single Answer)

Which of the following lines will compile without warning or error.

  1. float f=1.3;
  2. char c="a";
  3. int i=10;
  4. boolean b=null;
Question 17 Multiple Choice (Single Answer)

A byte can be of what size

  1. -128 to 127
  2. (-2 power 8 )-1 to 2 power 8
  3. -255 to 256
  4. 8
Question 18 Multiple Choice (Single Answer)

Which of the following are keywords or reserved words in Java?

  1. if
  2. then
  3. goto
  4. while
Question 19 Multiple Choice (Single Answer)

System.out.println(4 | 3);

  1. 6
  2. 0
  3. 1
  4. 7
Question 20 Multiple Choice (Single Answer)

What is the size for double data type in c#

  1. 1 Byte
  2. 2 Byte
  3. 4 Byte
  4. 8 Byte
  5. 16 Byte