wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Third Quarter - Comprog Review

Total questions: 140

Worksheet time: 1hrs 18mins

Name
Class
Date
1.

When does Exceptions in Java arises in code sequence?

a)

Run Time

b)

Compilation Time

c)

Can Occur Any Time

d)

None of the mentioned

2.

Which of these keywords is not a part of exception handling?

a)

try

b)

finally

c)

thrown

d)

catch

3.

Predict the output of following Java program

class Main {

public static void main(String args[]) {

try {

throw 10;

}

catch(int e) {

System.out.println("Got the Exception " + e);

}

}

}

a)

Got the Exception 10

b)

Got the Exception 0

c)

Compilation error

4.

class Test extends Exception { }

class Main {

public static void main(String args[]) {

try {

throw new Test();

}

catch(Test t) {

System.out.println("Got the Test Exception");

}

finally {

System.out.println("Inside finally block ");

}

}

}

a)

Got the Test Exception

Inside finally block

b)

Got the Test Exception

c)

Inside finally block

d)

Compiler Error

5.

Output of following Java program?

class Main {

public static void main(String args[]) {

int x = 0;

int y = 10;

int z = y/x;

}

}

a)

Compilation Error

b)

Compiles and runs fine

c)

Compiles fine but throws ArithmeticException exception

6.

class Test

{

public static void main (String[] args)

{

try

{

int a = 0;

System.out.println ("a = " + a);

int b = 20 / a;

System.out.println ("b = " + b);

}

catch(ArithmeticException e)

{

System.out.println ("Divide by zero error");

}

finally

{

System.out.println ("inside the finally block");

}

}

}

a)

Compile error

b)

Divide by zero error

c)

a = 0

Divide by zero error

inside the finally block

d)

a = 0

e)

inside the finally block

7.

Which of these is a super class of all errors and exceptions in the Java language?

a)

RunTimeExceptions

b)

Throwable

c)

Catchable

d)

None of the above

8.

The built-in base class in Java, which is used to handle all exceptions is

a)

Raise

b)

Exception

c)

Error

d)

Throwable

9.

Which of these keywords must be used to monitor for exceptions?

a)

try

b)

finally

c)

throw

d)

catch

10.

Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

a)

try

b)

finally

c)

throw

d)

catch

11.

Which of these keywords is used to manually throw an exception?

a)

try

b)

finally

c)

throw

d)

catch

12.

What will be the output of the following Java program?

class exception_handling {

public static void main(String args[]) {

try {

System.out.print("Hello" + " " + 1 / 0);

}

catch(ArithmeticException e) { System.out.print("World");

}

}

}

a)

Hello

b)

World

c)

HelloWorld

d)

Hello World

13.

What will be the output of the following Java program?

class exception_handling {

public static void main(String args[]) {

try {

int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

}

catch(ArithmeticException e) { System.out.print("B");

}

}

a)

A

b)

B

c)

Compilation Error

d)

Runtime Error

14.

What will be the output of the following Java program?

class exception_handling {

public static void main(String args[]) {

try {

int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

}

catch(ArithmeticException e) { System.out.print("B");

}

finally {

System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

15.

What will be the output of the following Java program?

class exception_handling {

public static void main(String args[]) {

try {

int i, sum;

sum = 10;

for (i = -1; i < 3 ;++i)

sum = (sum / i);

}

catch(ArithmeticException e) { System.out.print("0");

}

System.out.print(sum);

}

}

a)

0

b)

05

c)

Compilation Error

d)

Runtime Error

16.

Which of the following classes can catch all exceptions which cannot be caught?

a)

RuntimeException

b)

Error

c)

Exception

d)

ParentException

17.

Which of the following operators is used to generate instance of an exception which can be thrown using throw?

a)

thrown

b)

alloc

c)

malloc

d)

new

18.

Which of the following keyword is used by calling function to handle exception thrown by called function?

a)

throws

b)

throw

c)

try

d)

catch

19.

Which of the following handles the exception when a catch is not used?

a)

finally

b)

throw handler

c)

default handler

d)

java run time system

20.

Which part of code gets executed whether exception is caught or not?

a)

finally

b)

try

c)

catch

d)

throw

21.

Which of the following should be true of the object thrown by a thrown statement?

a)

Should be assignable to String type

b)

Should be assignable to Exception type

c)

Should be assignable to Throwable type

d)

Should be assignable to Error type

22.

At runtime, error is recoverable.

a)

True

b)

False

23.

Which of these class is related to all the exceptions that can be caught by using catch?

a)

Error

b)

Exception

c)

RuntimeExecption

d)

All of the mentioned

24.

Which of these class is related to all the exceptions that cannot be caught?

a)

Error

b)

Exception

c)

RuntimeExecption

d)

All of the mentioned

25.

What exception thrown by parseInt() method?

a)

ArithmeticException

b)

ClassNotFoundException

c)

NullPointerException

d)

NumberFormatException

26.

What will be the output of the following Java code?

class exception_handling {

public static void main(String args[]) {

try {

System.out.print("A");

throw new NullPointerException ("Hello");

}

catch(ArithmeticException e) { System.out.print("B");

}

}

}

a)

A

b)

B

c)

Hello

d)

Runtime Exception

27.

In which of the following package Exception class exist?

a)

java.io

b)

java.net

c)

java.lang

d)

java.util

28.

Which exception is thrown when divide by zero statement executes?

a)

NumberFormatException

b)

NullPointerException

c)

ArithmeticException

d)

None of the listed options

29.

When does Exceptions in Java arises in code sequence?

a)

Run Time

b)

Can Occur Any Time

c)

Compilation Time

d)

None of the mentioned

30.

What is the output of this program?

class Main

{

public static void main(String[] args)

{

try

{

return;

}

finally

{

System.out.println( "Finally" );

}

}

}

a)

Finally

b)

Compilation fails.

c)

The code runs with no output.

d)

An exception is thrown at runtime.

31.

What will be the output of the following Java code?

public class San {

public static void main(String args[]) {

try {

System.out.print("Hello world ");

}

finally {

System.out.println("Finally executing ");

}

}

}

a)

The program will not compile because no exceptions are specified

b)

The program will not compile because no catch clauses are specified

c)

Hello world

d)

Hello world Finally executing

32.

Which of these clause will be executed even if no exceptions are found?

a)

throws

b)

finally

c)

throw

d)

catch

33.

A single try block must be followed by which of these?

a)

finally

b)

catch

c)

finally & catch

d)

none of the mentioned

34.

Which of these exceptions will occur if we try to access the index of an array beyond its length?

a)

ArithmeticException

b)

ArrayException

c)

ArrayIndexException

d)

ArrayIndexOutOfBoundsException

35.

What will be the output of the following Java code?

class exception_handling {

public static void main(String args[]) {

try {

int a = args.length;

int b = 10 / a;

System.out.print(a);

}

catch (ArithmeticException e) {

System.out.println("1");

}

}

}

Note : Execution command line : $ java exception_handling

a)

0

b)

1

c)

Compilation Error

d)

Runtime Error

36.

What will be the output of the following Java code?

class exception_handling {

public static void main(String args[]) {

try {

throw new NullPointerException ("Hello");

}

catch(ArithmeticException e) { System.out.print("B");

}

}

}

a)

A

b)

B

c)

Compilation Error

d)

Runtime Error

37.

What will be the output of the following Java code?

class exception_handling {

public static void main(String args[]) {

try {

int a = 1;

int b = 10 / a;

try {

if (a == 1)

a = a / a - a;

if (a == 2)

{

int c[] = {1};

c[8] = 9;

}

}

finally {

System.out.print("A");

}

}

catch (Exception e) { System.out.println("B");

}

}

}

a)

A

b)

B

c)

AB

d)

BA

38.

What will be the output of the following Java code?

class exception_handling {

public static void main(String args[]) {

try {

int a = args.length;

int b = 10 / a;

System.out.print(a);

try {

if (a == 1)

a = a / a - a;

if (a == 2)

{

int []c = {1};

c[8] = 9;

}

}

catch (ArrayIndexOutOfBoundException e) {

System.out.println("TypeA");

}

catch (ArithmeticException e) { System.out.println("TypeB");

}

}

}

Note: Execution command line: $ java exception_handling one two

a)

TypeA

b)

TypeB

c)

Compilation Error

d)

Runtime Error

39.

What is the use of try & catch?

a)

It allows us to manually handle the exception

b)

It allows to fix errors

c)

It prevents automatic terminating of the program in cases when an exception occurs

d)

All of the mentioned

40.

Which of these keywords are used for the block to be examined for exceptions?

a)

try

b)

catch

c)

throw

d)

check

41.

Which of these statements is incorrect?

a)

try block need not to be followed by catch block

b)

try block can be followed by finally block instead of catch block

c)

try can be followed by both catch and finally block

d)

try need not to be followed by anything

42.

What will be the output of the following Java code?

class Output {

public static void main(String args[]) {

try {

int a = 0;

int b = 5;

int c = a / b;

System.out.print("Hello");

}

catch(Exception e) { System.out.print("World");

}

}

}

a)

Hello

b)

World

c)

HelloWOrld

d)

Compilation Error

43.

What will be the output of the following Java code?

class Output {

public static void main(String args[]) {

try {

int a = 0;

int b = 5;

int c = b / a;

System.out.print("Hello");

}

}

}

a)

Hello

b)

World

c)

HelloWOrld

d)

Compilation Error

44.

What will be the output of the following Java code?

class Output {

public static void main(String args[]) {

try {

int a = 0;

int b = 5;

int c = a / b;

System.out.print("Hello");

}

finally {

System.out.print("World");

}

}

}

a)

Hello

b)

World

c)

HelloWorld

d)

Compilation Error

45.

What will be the output of the following Java code?

class Output {

public static void main(String args[])

{

try

{

int a = 0;

int b = 5;

int c = b / a;

System.out.print("Hello");

}

catch(Exception e) { System.out.print("World");

}

finally {

System.out.print("World");

}

}

}

a)

Hello

b)

World

c)

HelloWorld

d)

WorldWorld

46.

Which of these methods return description of an exception?

a)

getException()

b)

getMessage()

c)

obtainDescription()

d)

obtainException()

47.

What will be the output of the following Java code?

class Myexception extends Exception

{

int detail;

Myexception(int a) {

detail = a;

}

public String toString() {

return "detail";

}

}

class Output {

static void compute (int a) throws Myexception {

throw new Myexception(a);

}

public static void main(String args[]) {

try {

compute(3);

}

catch(Myexception e) { System.out.print("Exception");

}

}

}

a)

3

b)

Exception

c)

Runtime Error

d)

Compilation Error

48.

What will be the output of the following Java code?

class Myexception extends Exception {

int detail;

Myexception(int a) {

detail = a;

}

public String toString() {

return "detail";

}

}

class Output {

static void compute (int a) throws Myexception

{

throw new Myexception(a);

}

public static void main(String args[]) {

try {

compute(3);

}

catch(DevideByZeroException e) { System.out.print("Exception");

}

}

}

a)

3

b)

Exception

c)

Runtime Error

d)

Compilation Error

49.

What will be the output of the following Java code?

class exception_handling {

public static void main(String args[]) {

try {

throw new NullPointerException ("Hello"); System.out.print("A");

}

catch(ArithmeticException e) { System.out.print("B");

}

}

}

a)

A

b)

B

c)

Compilation Error

d)

Runtime Error

50.

Which of these class is highest in hierarchy in java ?

a)

java.lang.Exception

b)

java.lang.Error

c)

java.lang.Throwable

d)

java.lang.Object

51.

Exception and Error are direct subclasses of?

a)

BaseException

b)

Throwable

c)

Object

d)

RuntimeException

52.

What is the list nums if it is initially [5, 3, 1] and the following code is executed?

nums.add(6);

nums.add(0, 4);

nums.remove(1);

num.set(0, 5);

a)

[4, 3, 1, 6]

b)

[5, 3, 1, 6]

c)

[4, 3, 6]

d)

[4, 5, 3, 6]

53.

What index value is used to locate the last element in the list ArrayList?

a)

list.size()-1

b)

list.length()-1

c)

list.size()

d)

list.length

54.

Which statement below is the correct way to retrieve the second element in the list ArrayList?

a)

list.get(1)

b)

list[2]

c)

list(1)

d)

list[2]

55.

Given the ArrayList list with the values [3, 7, 6, 0], what code below is the proper way to change the 0 to be a 9?

a)

list.set(0, 9)

b)

list.set(9, 0)

c)

list.set(3, 9)

d)

list[3] = 9

56.

Given the nums ArrayList with the values [5, 4, 3, 2], what statement below removes the value 4 from the list?

a)

nums.remove(4)

b)

nums.remove(1)

c)

nums.get(4) = null

d)

nums.remove[1]

57.

Given the nums ArrayList with the values [1, 2, 4, 5, 6], what code below can be used to add a 3 between the 2 and 4 in the list?

a)

nums.add(2, 3)

b)

nums.add(2, 4)

c)

nums.add(3, 2)

d)

nums.add(3)

58.

What will print when the following code executes?

ArrayList<Integer> list = new ArrayList<Integer>();

list.add(7);

list.add(8);

list.add(9);

list.add(1);

System.out.println(list.remove(1));

a)

8

b)

1

c)

9

d)

7

59.

What is printed as a result of executing the following code?

ArrayList<Integer> alist = new ArrayList<Integer>();

alist.add(1);

alist.add(2);

alist.remove(1);

alist.add(1, 3);

alist.set(1, 4);

alist.add(5);

alist.set(0, 2);

System.out.println(alist);

a)

[1, 4, 5]

b)

[1, 4, 3, 5]

c)

[2, 4, 5]

d)

[2, 4, 3, 5]

60.

What is printed as a result of executing the following code segment?

ArrayList<Double> vals = new ArrayList<Double>();

vals.add(3.5);

vals.add(4.5);

vals.add(5.5);

vals.add( vals.set(0, 2.5) );

vals.remove(3);

System.out.println(vals);

a)

[2.5, 4.5, 5.5, 3.5]

b)

[2.5, 3.5, 4.5, 5.5]

c)

[3.5, 4.5, 5.5, 2.5]

d)

[2.5, 4.5, 5.5]

61.

Which statement is the correct declaration and initialization of an ArrayList of Integer values?

a)

ArrayList<Integer> name;

name = new ArrayList<Integer>();

b)

ArrayList name;

name = new ArrayList<Integer>();

c)

ArrayList<Integer> name;

name = ArrayList<Integer>();

d)

Integer<ArrayList> name;

name = new Integer<ArrayList>();

62.

What is printed as a result of executing the following code on an ArrayList of Integers called nums with the values [3, 2, -4, 8, 7]?

for (int idx = 0; idx < nums.size(); idx++)

if (nums.get(idx) % 2 == 0)

nums.add(99);

System.out.println(nums.size());

a)

7

b)

5

c)

8

d)

memory full because too many values added

63.
Which is correct syntax to access an element of an ArrayList in Java?
a)

list.get(index)

b)

list[index]

c)

list.getElement(index)

d)

list.index

64.
What does it mean for a list to be "dynamic"?
a)
You can easily add and remove elements
b)
It has a set size once it has been created
c)
It may contain multiple types of values
d)
You can access it from anywhere in the program
65.
How do you get the number of elements in an ArrayList called "list" in Java?
a)
list.size();
b)
list.count();
c)
list.length();
d)
list.getSize();
66.
The _________ method will return the total elements in an ArrayList.
a)
total()
b)
length()
c)
size()
d)
length
67.

Which of these class is superclass of String and StringBuffer class?

a)

java.util

b)

java.lang

c)

ArrayList

d)

None of the mentioned

68.

Which of these is an incorrect statement?

a)

String objects are immutable, they cannot be changed

b)

String object can point to some other reference of String variable

c)

StringBuffer class is used to store string in a buffer for later use

d)

None of the mentioned

69.

What is the output of this program?

class String_demo{

public static void main(String args[])

{

char chars[] = {'a', 'b', 'c'};

String s = new String(chars);

System.out.println(s);

}

}

a)

a

b)

b

c)

c

d)

abc

70.

What is the output of this program?

class String_demo {

public static void main(String args[]){

int ascii[] = { 65, 66, 67, 68};

String s = new String(ascii, 1, 3);

System.out.println(s);

}

}

a)

ABC

b)

BCD

c)

CDA

d)

ABCD

71.

What is the output of this program?

class String_demo{

public static void main(String args[]){

char chars[] = {'a', 'b', 'c'};

String s = new String(chars);

String s1 = "abcd";

int len1 = s1.length();

int len2 = s.length();

System.out.println(len1 + " " + len2);

}

}

a)

3 0

b)

0 3

c)

3 4

d)

4 3

72.

Which of the following statements are incorrect?

a)

String is a class

b)

Strings in java are mutable

c)

Every string is an object of class String

d)

Java defines a peer class of String, called StringBuffer, which allows string to be altered

73.

What is the output of following program?

class string_class{

public static void main(String args[]){

String obj = "hello";

String obj1 = "world";

String obj2 = obj;

obj2 = " world";

System.out.println(obj + " " + obj2);

}

}

a)

hello hello

b)

world world

c)

hello world

d)

world hello

74.

toString() method is defined in

a)

java.lang.String

b)

java.lang.Object

c)

java.lang.util

d)

None of these

75.

The String method compareTo() returns

a)

true

b)

false

c)

an int value

d)

1

76.

The class string belongs to ................. package.

a)

java.awt

b)

java.lang

c)

java.applet

d)

java.string

77.

Is String a primitive data type?

a)

Yes

b)

No

c)

Both

78.

Which method to use to find length of a string?

a)

length()

b)

size()

c)

long()

d)

count()

79.

Which data type gets returned from length() method in String class?

a)

double

b)

String

c)

int

d)

number

80.

String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


What is the correct way to find the length of "txt" string?

a)

int len = length(txt);

b)

float len = txt.length();

c)

int len = txt.length();

d)

double len = length(txt);

81.

Which is correct method to convert String into uppercase

a)

changeUpperCase()

b)

convertUpperCase()

c)

toUpper()

d)

toUpperCase()

82.

String txt = "Hello World";

System.out.println(txt.toUpperCase());


Choose the correct output.

a)

"HELLO WORLD"

b)

HELLO WORLD

c)

Hello world

d)

Hello World

83.

Choose correct purpose of indexOf() in String class.

a)

returns the index (the position) of the last occurrence of a specified text in a string

b)

returns the character of the first occurrence of a specified character in a string

c)

returns the index (the position) of the first occurrence of a specified text in a string (excluding whitespace)

d)

returns the index (the position) of the first occurrence of a specified text in a string (including whitespace)

84.

String firstName = "John ";

String lastName = "Doe";

System.out.println(firstName.concat(lastName));


Guess the output.

a)

John.concat(Doe)

b)

John Doe

c)

JohnDoe

d)

"John Doe"

85.

String x = "10";

String y = "20";

String z = x + y;


Guess the output.

a)

1020

b)

10 20

c)

30

d)

"10 20"

86.

What will be the output of below code?


String statement = "Outfit of the day";

System.out.println(statement.Substring(3,6));

a)

it of

b)

tfit

c)

fit

d)

FIT

87.

What is the most appropriate way to check if two Strings are equal?

a)

string1 == string2

b)

string1.equals(string2)

c)

string1.same(string2)

d)

string1.equalsIgnorecase(string2)

88.

Pick all NON-primitive datatypes from below :

a)

String

b)

int

c)

primitive

d)

Array

89.
String word = "A few good men";
What is word.length()?
a)
14
b)
15
c)
13
90.
String word = "A few good men";
What is word.charAt(7) ?
a)
o
b)
g
c)
7
d)
good men
91.
String word = "A few good men";
What is word.startsWith("A few") ?
a)
true
b)
false
92.
String word = "A few good men";
What is word.endsWith("man") ?
a)
true
b)
false
93.
String word = "A few good men";
What is word.indexOf(“f”)?
a)
2
b)
0
c)
1
d)
-1
94.
String word = "A few good men";
What is word.indexOf(“bad”)?
a)
0
b)
-1
c)
3
95.
String word = "A few good men";
What is word.substring(3, 7) ?
a)
ew g
b)
ew go
c)
few
d)
few[space]
96.

Nested classes are classes defined inside bottom-level classes.

a)

True

b)

False

97.

Static nested classes can directly access the members of the class where are defined.

a)

True

b)

False

98.

Top-level classes are easily specified inside a package.

a)

True

b)

False

99.

Static nested classes are also defined within the top-level class but exist in isolation.

a)

True

b)

False

100.

Non-static nested classes are declared inside the top-level classes.

a)

True

b)

False

101.

To define a collection of constants, Java uses a special type known as _______.

a)

enum

b)

static

c)

inner class

d)

nested class

102.

Enum keyword signifies a distinct data type that allows a variable to belong to a set of predefined _________.

a)

enum

b)

constants

c)

static

d)

collection

103.

You cannot declare enum inside the class.

a)

True

b)

False

104.

The values defined within an enum are constants and shall be entered in ___________ letters

a)

lowercase

b)

camel case

c)

proper case

d)

uppercase

105.

If an enum is a member of a class, then it is indirectly classified as _______.

a)

enum

b)

constants

c)

void

d)

static

106.

An inner class can be private

a)

True

b)

False

107.

Once you declare an inner class private, it cannot be accessed from an object outside the class.

a)

True

b)

False

108.

The user can also use enum in ____________ to obtain an array of possible values.

a)

enumeration

b)

iteration

c)

nested class

d)

inner class

109.

Enum can used together with if and switch statements to compare a variable pointing to an enum constant.

a)

True

b)

False

110.

Enum should be used when it is necessary to define and denote a fixed set of constants.

a)

True

b)

False

111.

Which of the following is the SQL statement to verify that the table named "SUPPLY" is existing in the database?

a)

SHOW SUPPLY;

b)

VERIFY SUPPLY;

c)

DESC SUPPLY;

d)

DROP SUPPLY;

112.

Which of the following is the correct SQL statement to delete the entire table named "WORKER"?

a)

DROP TABLE WORKER;

b)

DELETE DATABASE WORKER;

c)

DELETE TB WORKER;

d)

DELETE TABLE WORKER;

113.

It is a column in a table that is designed to maintain specific information about every record in the table

a)

Record

b)

Field

c)

Table

d)

Row

114.

It is also called a row of data is each individual entry that exists in a table

a)

Record

b)

Column

c)

Database

d)

Field

115.

Which of the following is NOT an EXACT DATA TYPE?

a)

smallint

b)

real

c)

tinyint

d)

money

116.

A character string data type with a maximum length of 2,147,483,647 characters.

a)

varchar

b)

char

c)

text

d)

smallmoney

117.

Which of the following is the correct SQL statement to create a new database called STAFF?

a)

CREATE DB STAFF;

b)

CREATE DATABASE STAFF;

c)

DB CREATE STAFF;

d)

DATABASE CREATE STAFF;

118.

Which of the following is the correct SQL statement to delete the database named "SCHOOL"?

a)

DROP DB SCHOOL;

b)

DROP DATABASE SCHOOL;

c)

DELETE DB SCHOOL;

d)

DELETE DATABASE SCHOOL;

119.

Which of the following is the correct SQL statement to show all the existing databases?

a)

USE DATABASES;

b)

SHOW DATABASES;

c)

SHOW DB;

d)

DESC DATABASES;

120.

Which of the following is NOT true about NULL?

a)

A field with no value

b)

A value in a field that appears to be blank

c)

A field that contains spaces

d)

It is different from zero value

121.

What does SQL stand for?

a)

Structured Query Language

b)

Structured Question Language

c)

Strong Question Language

122.

Which SQL statement is used to extract data from a database?

a)

SELECT

b)

OPEN

c)

GET

d)

EXTRACT

123.

Which SQL statement is used to update data in a database?

a)

UPDATE

b)

SAVE

c)

MODIFY

d)

SAVE AS

124.

Which SQL statement is used to insert new data in a database?

a)

INSERT INTO

b)

ADD NEW

c)

ADD RECORD

d)

INSERT NEW

125.

With SQL, how do you select a column named "FirstName" from a table named "Persons"?

a)

SELECT FirstName FROM Persons

b)

SELECT Persons.FirstName

c)

EXTRACT FirstName FROM Persons

126.

With SQL, how do you select all the columns from a table named "Persons"?

a)

SELECT * FROM Persons

b)

SELECT *.Persons

c)

SELECT [all] FROM Persons

d)

SELECT Persons

127.

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?

a)

SELECT * FROM Persons WHERE FirstName='Peter'

b)

SELECT [all] FROM Persons WHERE FirstName='Peter'

c)

SELECT * FROM Persons WHERE FirstName<>'Peter'

d)

SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

128.

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?

a)

SELECT * FROM Persons WHERE FirstName LIKE 'a%'

b)

SELECT * FROM Persons WHERE FirstName LIKE '%a'

c)

SELECT * FROM Persons WHERE FirstName='%a%'

d)

SELECT * FROM Persons WHERE FirstName='a'

129.

With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"?

a)

SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

b)

SELECT FirstName='Peter', LastName='Jackson' FROM Persons

c)

SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'

130.

With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

a)

SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

b)

SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName<'Pettersen'

c)

SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons

131.

Which SQL statement is used to return only different values?

a)

SELECT DISTINCT

b)

SELECT DIFFERENT

c)

SELECT UNIQUE

132.

Which SQL keyword is used to sort the result-set?

a)

ORDER BY

b)

SORT BY

c)

ORDER

d)

SORT

133.

With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?

a)

SELECT * FROM Persons ORDER BY FirstName DESC

b)

SELECT * FROM Persons ORDER FirstName DESC

c)

SELECT * FROM Persons SORT BY 'FirstName' DESC

d)

SELECT * FROM Persons SORT 'FirstName' DESC

134.

With SQL, how can you insert a new record into the "Persons" table?

a)

INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

b)

INSERT ('Jimmy', 'Jackson') INTO Persons

c)

INSERT VALUES ('Jimmy', 'Jackson') INTO Persons

135.

With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

a)

INSERT INTO Persons (LastName) VALUES ('Olsen')

b)

INSERT INTO Persons ('Olsen') INTO LastName

c)

INSERT ('Olsen') INTO Persons (LastName)

136.

How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

a)

UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

b)

UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'

c)

MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'

d)

MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen

137.

With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

a)

DELETE FROM Persons WHERE FirstName = 'Peter'

b)

DELETE ROW FirstName='Peter' FROM Persons

c)

DELETE FirstName='Peter' FROM Persons

138.

With SQL, how can you return the number of records in the "Persons" table?

a)

SELECT COUNT(*) FROM Persons

b)

SELECT LEN(*) FROM Persons

c)

SELECT NO(*) FROM Persons

d)

SELECT COLUMNS(*) FROM Persons

139.

Which operator is used to select values within a range?

a)

BETWEEN

b)

WITHIN

c)

RANGE

140.

Which operator is used to search for a specified pattern in a column?

a)

FROM

b)

LIKE

c)

GET