4
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:   D) 15 0 20



Explanation:
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 1639
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 1956
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 2677
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 1684
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 1637
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 2949
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 2230
Q:

Difference between Candidate key and Primary key?

Answer

Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. 


Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key.






        • One needs to be very careful in selecting the Primary Key as an incorrect selection can adversely impact the database architect and future normalization. For a Candidate Key to qualify as a Primary Key, it should be Non-NULL and unique in any domain.




Report Error

View answer Workspace Report Error Discuss

6 3541