6
Q:

In the following pieces of code, B and D will compile without any error. True or false ?

A: StringBuffer sb1 = "abcd";

B: Boolean b = new Boolean("abcd");

C: byte b = 255;

D: int x = 0x1234;

E: float fl = 1.2;

 

A) TRUE B) FALSE

Answer:   A) TRUE



Explanation:

The code segments B and D will compile without any error. A is not a valid way to construct a StringBuffer, you need to create a StringBuffer object using "new". B is a valid construction of a Boolean (any string other than "true" or "false" to the Boolean constructor will result in a Boolean with a value of "false"). C will fail to compile because the valid range for a byte is -128 to +127 (i.e., 8 bits, signed). D is correct, 0x1234 is the hexadecimal representation in java. E fails to compile because the compiler interprets 1.2 as a double being assigned to a float (down-casting), which is not valid. You either need an explicit cast, as in "(float)1.2" or "1.2f", to indicate a float.

Q:

Difference between Union and Union all?

Answer

The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table. A UNION statement effectively does a SELECT DISTINCT on the results set.

Report Error

View answer Workspace Report Error Discuss

1 1396
Q:

A subquery in an sql select statement.

Answer

A Subquery or Inner query or a Nested query is a query within another SQL query and embedded within the WHERE clause.


Subqueries are most frequently used with the SELECT statement. The basic syntax is as follows::


SELECT column_name [, column_name ]
FROM table1 [, table2 ]
WHERE column_name OPERATOR
(SELECT column_name [, column_name ]
FROM table1 [, table2 ]
[WHERE])



A subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved.


Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the operators like =, <, >, >=, <=, IN, BETWEEN, etc.


 


There are a few rules that subqueries must follow −


 


1. Subqueries must be enclosed within parentheses.


2. A subquery can have only one column in the SELECT clause, unless multiple columns are in the main query for the subquery to compare its selected columns.


3. An ORDER BY command cannot be used in a subquery, although the main query can use an ORDER BY. The GROUP BY command can be used to perform the same function as the ORDER BY in a subquery.


4. Subqueries that return more than one row can only be used with multiple value operators such as the IN operator.


5. The SELECT list cannot include any references to values that evaluate to a BLOB, ARRAY, CLOB, or NCLOB.


6. A subquery cannot be immediately enclosed in a set function.


7. The BETWEEN operator cannot be used with a subquery. However, the BETWEEN operator can be used within the subquery.

Report Error

View answer Workspace Report Error Discuss

0 1623
Q:

The SQL keyword BETWEEN is used:

A) for ranges B) as a wildcard
C) to limit the columns displayed D) All the above
 
Answer & Explanation Answer: A) for ranges

Explanation:

In SQL, BETWEEN Keyword is used for ranges like Number Ranges, Date Ranges, etc...

Report Error

View Answer Report Error Discuss

0 2414
Q:

Candidate Key in DBMS?

Answer

A candidate key is a column, or set of columns, in a table that can uniquely identify any database record without referring to any other data. Each table may have one or more candidate keys, but one candidate key is unique, and it is called the primary key.

Report Error

View answer Workspace Report Error Discuss

1 1539
Q:

Foreign key in DBMS is

Answer

Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables.


 


In detail : A Foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table or the same table. In simpler words, the foreign key is defined in a second table, but it refers to the primary key or a unique key in the first table.

Report Error

View answer Workspace Report Error Discuss

1 1367
Q:

A Transparent DBMS

A) Keep its logical structure hidden from users B) Can access control
C) Keeps its physical structure hidden from users D) Can not hide sensitive information from users
 
Answer & Explanation Answer: C) Keeps its physical structure hidden from users

Explanation:

DBMS :: Database Managemet System.

A DBMS which keeps its physical structure hidden from the user is known as a transparent DBMS.

Report Error

View Answer Report Error Discuss

2 2613
Q:

What is Primary Key in DBMS?

Answer

A primary key is a special relational database table column or combination of columns designated to uniquely identify all table records. That is, A primary key is a column or set of columns in a table that uniquely identifies tuples (rows) in that table.


A primary key, also called a Primary Keyword.



Main Features Primary key are ::


It must contain a unique value for each row of data.


It cannot contain null values.

Report Error

View answer Workspace Report Error Discuss

10 1946
Q:

what will be the output of the following code?

class Value
{
    public int i = 15;
}
public class Test
{
    public static void main(String argv[])
    {
        Test t = new Test();
        t.first();
    }
    public void first()
    {
        int i = 5;
        Value v = new Value();
        v.i = 25;
        second(v, i);
        System.out.println(v.i);
    }
    public void second(Value v, int i)
    {
        i = 0;
        v.i = 20;
        Value val = new Value();
        v =  val;
        System.out.println(v.i + " " + i);
    }
}

A) 15 0 2 B) 15 0 0
C) 15 20 0 D) 15 0 20
 
Answer & Explanation Answer: D) 15 0 20

Explanation:
Report Error

View Answer Report Error Discuss

3 4563