programming languages Online Quiz - 318
programming languages Online Quiz - 318
Questions
Which functions are available in SQL?
- string and date
- character and numeric
- integer and conversion
- calendar and date
- date and conversion
- translation and date
Which three are true?
- A MERGE statement is used to merge the data of one table with data from another.
- A MERGE statement can be used to update existing rows in a table.
- A MERGE statement replaces the data of one table with that of another.
- A MERGE statement can be used to insert new rows into a table.
Which statements are true about constraints?
- The UNIQUE constraint does not permit a null value for the column.
- The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index.
- The NOT NULL constraint ensures that null values are not permitted for the column.
- A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.
Which statements about subqueries are true?
- A subquery should retrieve only one row.
- A subquery can retrieve zero or more rows.
- Subqueries CANNOT be nested by more than two levels.
- A subquery can be used only in SQL query statements.
- A subquery CANNOT be used in an SQL query statement that uses group functions.
- When a subquery is used with an inequality comparison operator in the outer SQL statement,
Which view should a user query to display the columns associated with the constraints on a table owned by the user?
- USER_CONSTRAINTS
- USER_OBJECTS
- ALL_CONSTRAINTS
- USER_CONS_COLUMNS
- USER_COLUMNS
The user Alice wants to grant all users query privileges on her DEPT table. Which SQL statement accomplishes this?
- GRANT select ON dept TO ALL_USERS;
- GRANT select ON dept TO ALL;
- GRANT QUERY ON dept TO ALL_USERS
- GRANT select ON dept TO PUBLIC;
- GRANT QUERY ON dept TO PUBLIC;
Which constraint can be defined only at the column level?
- UNIQUE
- NOT NULL
- CHECK
- PRIMARY KEY
- FOREIGN KEY
In which cases would you use an outer join?
- The tables being joined have NOT NULL columns.
- The tables being joined have only matched data.
- The columns being joined have NULL values.
- The tables being joined have only unmatched data.
- The tables being joined have both matched and unmatched data.
- Only when the tables have a primary key/foreign key relationship.
Given: 11. public static void test(String str) { 12. int check = 4; 13. if (check = str.length()) { 14. System.out.print(str.charAt(check -= 1) +“, “); 15. } else { 16. System.out.print(str.charAt(0) + “, “); 17. } 18. } and the invocation: 21. test(”four”); 22. test(”tee”); 23. test(”to”); What is the result?
- r, t, t,
- r, e, o,
- Compilation fails.
- An exception is thrown at runtime.
Given: 11. public static void test(String str) { 12. int check = 4; 13. if (check = str.length()) { 14. System.out.print(str.charAt(check -= 1) +“, “); 15. } else { 16. System.out.print(str.charAt(0) + “, “); 17. } 18. } and the invocation: 21. test(”four”); 22. test(”tee”); 23. test(”to”); What is the result?
- r, t, t,
- r, e, o,
- Compilation fails.
- An exception is thrown at runtime.
A class games.cards.Poker is correctly defined in the jar file Poker.jar. A user wants to execute the main method of Poker on a UNIX system using the command: java games.cards.Poker What allows the user to do this? A. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java B. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/.jar C. Put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/Poker.jar D. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java E. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuffijava/.jar F. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/Poker.jar
- A
- B
- C
- D
- E
- F
What is the result of compiling and running this program? class Clove{ void quality(Clove m){ System.out.println("Clove is nice"); } } class Mint extends Clove{ void quality(Mint c){ System.out.println("Mint is ok"); } } class Sage extends Mint{ void quality(Sage h){ System.out.println("Sage is average"); } } public class Test{ public static void main(String[] args){ Clove h = new Sage(); Mint c = new Sage(); c.quality(h); } }
- prints "Clove is nice"
- prints "Mint is ok"
- prints "Sage is average"
- Class cast Exception at runtime.
What will this program print out ? class Base{ int value = 0; Base(){ addValue(); } void addValue(){ value += 10; } int getValue(){ return value; } } class Derived extends Base{ Derived(){ addValue(); } void addValue(){ value += 20; } } public class Test { public static void main(String[] args){ Base b = new Derived(); System.out.println(b.getValue()); } }
- 10
- 20
- 30
- 40
Given classes defined in two different files: 1. package util; 2. public class BitUtils { 3. private static void process(byte[] b) { } 4. } 1. package app; 2. public class SomeApp { 3. public static void main(String[] args) { 4. byte[] bytes = new byte[256]; 5. // insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils?
- process(bytes);
- BitUtils.process(bytes);
- app.BitUtils.process(bytes);
- util.BitUtils.process(bytes);
- import util.BitUtils. *; process(bytes);
- SomeApp cannot use the process method in BitUtils.
class Abc { int i=initialize(369); int j=initialize(); public int initialize() { return 318; } public void initialize(int i) { this.i=i; } public static void main(String a[]) { Abc abc=new Abc(); System.out.println("i="+abc.i); abc.initialize(369); System.out.println("after i="+abc.i); System.out.println("j="+abc.j); } }
- Error: Non static method intialize cannot accessed from static context main
- Error: Method initialize is already defined
- i=0 after i=369 j=318
- Error: incompatible types
Given: 1. public class Threads4 { 2. public static void main (String[] args) { 3. new Threads4().go(); 4. } 5. public void go() { 6. Runnable r = new Runnable() { 7. public void run() { 8. System.out.print(”foo”); 9. } 10. }; 11. Thread t = new Thread(r); 12. t.start(); 13. t.start(); 14. } 15. } What is the result?
- Compilation fails.
- An exception is thrown at runtime.
- The code executes normally and prints ‘foo”.
- The code executes normally, but nothing is printed.
Given classes defined in two different files: 1. package util; 2. public class BitUtils { 3. public static void process(byte[]) { /* more code here */ } 4. } 1. package app; 2. public class SomeApp { 3. public static void main(String[] args) { 4. byte[] bytes = new byte[256]; 5. // insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils?
- process(bytes);
- BitUtils.process(bytes);
- util.BitUtils.process(bytes);
- SomeApp cannot use methods in BitUtils.
- import util.BitUtils.*; process(bytes);
Given: 11. // insert code here 12. private N min, max; 13. public N getMin() { return min; } 14. public N getMax() { return max; } 15. public void add(N added) { 16. if (min == null || added.doubleValue() <min.doubleValue()) 17. min = added; 18. if (max == null ||added.doubleValue() > max.doubleValue()) 19. max = added; 20. } 21. } Which two, inserted at line 11, will allow the code to compile? (Choose two.)
- public class MinMax<?> {
- public class MinMax<? extends Number> {
- public class MinMax<N extends Object> {
- public class MinMax<N extends Number> {
- public class MinMax<? extends Object> {
- public class MinMax<N extends Integer> {
class Abc { static { System.out.print("Static block "); display(); } public void display() { System.out.print("Display block "); } public static void main(String a[]) { System.out.print("Starting of Main block "); Abc abc=new Abc(); System.out.print("In the Main block "); abc.display(); } }
- Starting of Main block Static block In the Main block Display block
- Static block Display block Starting of Main block In the Main block Display block
- Error: Non static method cannot accessed from static context
- Starting of Main block In the Main block Display block