Java and SQL Programming Fundamentals

Test your knowledge of Java APIs, threading, exceptions, OOP concepts, and SQL queries in this programming fundamentals quiz.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Given: 1. class Ring { 2. final static int x2 = 7; 3. final static Integer x4 = 8; 4. public static void main(String[] args) { 5. Integer x1 = 5; 6. String s = "a"; 7. if(xl < 9) s += "b"; 8. switch(x1) { 9. case 5: s += "c"; 10. case x2: s += "d"; 11. case x4: s += "e"; 12. } 13. System.out.println(s); 14. } 15. } What is the result?

  1. abc
  2. abcde
  3. Compilation fails due only to an error on line 7.
  4. Compilation fails due only to an error on line 8.
  5. Compilation fails due only to an error on line 10.
  6. Compilation fails due only to an error on line 11.
Question 2 Multiple Choice (Single Answer)

System.out.format("Pi is approximately %d.", Math.PI); What is the result?

  1. Compilation fails
  2. Pi is approximately 3
  3. Pi is approximately 3.141593
  4. An exception is thrown at runtime
Question 3 Multiple Choice (Multiple Answers)

Which two statements are true about has-a and is-a relationships? (Choose two.)

  1. Inheritance represents an is-a relationship
  2. . Inheritance represents a has-a relationship
  3. Interfaces must be used when creating a has-a relationship
  4. Instance variables can be used when creating a has-a relationship
Question 4 Multiple Choice (Single Answer)

public static void test(String str) { if (str == null | str.length() == 0) { System.out.println("String is empty"); } else { System.out.println("String is not empty"); } } And the invocation: test(null); What is the result?

  1. An exception is thrown at runtime.
  2. "String is empty" is printed to output
  3. Compilation fails
  4. "String is not empty" is printed to output.
Question 5 Multiple Choice (Single Answer)

public class TestOne { public static void main (String[] args) throws Exception { Thread.sleep(3000); System.out.println("sleep"); } } What is the result?

  1. Compilation fails.
  2. An exception is thrown at runtime.
  3. The code executes normally and prints "sleep".
  4. The code executes normally, but nothing is print ed.
Question 6 True/False

It is recommended to overload run() in your Thread class

  1. True
  2. False
Question 7 Multiple Choice (Multiple Answers)

1 String #name = "Jane Doe"; 2 int $age = 24; 3 Double _height = 123.5; 4 double ~temp = 37.5; Which two statements are true?

  1. . Line 1 will not compile
  2. . Line 2 will not compile
  3. . Line 3 will not compile
  4. . Line 4 will not compile
Question 8 Multiple Choice (Single Answer)

The primary key on table EMP is the EMPNO column. Which of the following statements will not use the associated index on EMPNO?

  1. select * from EMP where nvl(EMPNO, '00000') = '59384';
  2. select * from EMP where EMPNO = '59384';
  3. select EMPNO, LASTNAME from EMP where EMPNO = '59384';
  4. select 1 from EMP where EMPNO = '59834';
Question 9 Multiple Choice (Single Answer)

Assuming today is Monday, 10 July 2000, what is returned by this statement: SELECT to_char(NEXT_DAY(sysdate, 'MONDAY'), 'DD-MON-RR') FROM dual;

  1. 03-JUL-00
  2. 10-JUL-00
  3. 11-JUL-00
  4. 17-JUL-00
Question 10 Multiple Choice (Single Answer)

How many columns are presented after executing this query: SELECT address1||','||address2||','||address2 "Adress" FROM employee;

  1. 0
  2. 1
  3. 3
  4. 2
Question 11 Multiple Choice (Single Answer)

Which character function can be used to return a specified portion of a character string?

  1. INSTR
  2. SUBSTRING
  3. SUBSTR
  4. POS
Question 12 Multiple Choice (Single Answer)

Which character is used to continue a statement in SQL*Plus?

  1. *
  2. /
  3. -
  4. --
Question 13 Multiple Choice (Single Answer)

This Contains all of the classes for creating user interfaces and for painting graphics and images

  1. java.lang
  2. java.util
  3. java.awt
  4. java.graphics
Question 14 Multiple Choice (Single Answer)

What does API stand for?

  1. Assignment Programming Interface
  2. Application Programming Interface
  3. Active Program Interface
  4. None of the above
Question 15 Multiple Choice (Single Answer)

Which API provides classes that are fundamental to the design of the Java programming language?

  1. Java.lang
  2. Java.nio
  3. Java.rmi
  4. Java.basic
Question 16 True/False

java.sql API is used for accessing and processing data stored in a data source (usually a relational database) using the Java programming language

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

Which of the following is not a Java API?

  1. java.nio
  2. java.text
  3. java.xml
  4. java.io
Question 18 Multiple Choice (Single Answer)

Which of the following APIs provides the classes and interfaces for the security framework?

  1. java.io
  2. java.rmi
  3. java.security
  4. None of the above
Question 19 Multiple Choice (Single Answer)

COBOL stands for:

  1. Combined Business-Oriented Language
  2. Combined Business-OnLine Language
  3. Common Business-Oriented Language
  4. Common Business online Language
Question 20 Multiple Choice (Single Answer)

These element according to COBOL programming standard need not to be vertically aligned:

  1. PICTURE clauses
  2. VALUE clauses
  3. 'TO' in the statements
  4. All COBOL verbs