java practice

¡Supera tus tareas y exámenes ahora con Quizwiz!

Q: The *BLANK* is the superclass of every class in Java?

*BLANK* = Object Class

Q: A *BLANK* update is an Update statement without a Where clause, thus updating all the records in the table.

*BLANK* = global

Q: The *BLANK* keyword is used by the method to refer to the object that invoked it.

*BLANK* = this

Q: You would use the keyword *BLANK1* in conjunction with the *BLANK2* in the Where clause for a pattern/wildcard search?

*BLANK1* = Like *BLANK2* = %

Q: What will be the output of the following Java code? public static void main(String args[]) { int var1 = 5; int var2 = 6; System.out.print(var1 > var2); }

ANSWER: false

Q: If you don't specify ASC or DESC after a SQL ORDER BY clause, the following is used by default ______________

ASC

Q: What keywords do you use in the Order By clause to determine ascending or descending order?

ASC and DESC (default is ASC)

Q: What keywords do you use in the Order By clause to determine ascending or descending order?

ASC for ascending and DESC for descending

Q: What built-in function do you use to get the average?

AVG()

Q: What statement would you use to modify tables in a database?

Alter Table

Q: What statement would you use to update and modify tables in a database?

Alter Table Statement

Q: What's the difference between a hard delete and a soft delete?

Hard delete physically removes the record from the table. A soft delete updates a designated field to indicate an inactive/active or delete/active status.

Q: Can there be an abstract method without an abstract class?

no If there is an abstract method in a class, that class must be abstract.

Q: What is the return type of Constructors?

none Constructors do not have any return type.

Q: What are the 3 different types of relationships between tables in your data model?

one to one one to many many to many

Q: What is database normalization?

Separating the entities in your data model and place them in separate related tables, linked by foreign key constraints, so that the same information does not appear more than once in the database

Q: What is the use of final keyword in Java?

a. When a class is made final, a subclass of it can not be created. b. When a method is final, it can not be overridden. c. When a variable is final, it can be assigned value only once. d. All of the above ANSWER = d

Q: What are the 3 different types of relationships between tables in your data model?

Many-to-Many One-to-One One-to-Many

Q: What is the process of defining more than one method in a class differentiated by parameters?

Method overloading

Q: Which of these can be overloaded?

Methods and Constructors

Q: Match the definition to HashSet or HashMap

Can only contain one NULL value. → HashSet, Includes key-value pairs. → HashMap, Can only contain one NULL key. → HashMap, Cannot have duplicate values. → HashSet

Q: Which of the following is not an OOP concept in Java?

Compilation

Q: Which of these cannot be declared static?

From the list of: variable method class object ANSWER = object Static statements are run as soon as the class containing them is loaded, prior to any object declaration.

Q: What are the 4 types of joins?

inner join left outer join right outer join full outer join

Q: Which of these is an incorrect array declaration? (Choose all the apply)

int arr[] = int [5] new AND int arr[] = new int[]

Q: What does a global update do?

It's an Update statement without a Where clause, thus updating all the records in the table.

Q: Which SQL function is used to count the number of rows in a SQL query?

COUNT()

Q: Decrement operator, −−, decreases the value of variable by what number?

1

Q: Which of the following is/are true about constructors in Java?

1. Constructor name should be same as class name. 2. If you don't define a constructor for a class, a default parameterless constructor is automatically created by the compiler. 3. The default constructor calls super() and initializes all instance variables to default value like 0, null. 4. If we want to parent class constructor, it must be called in first line of constructor. ANSWER = 1, 2, 3, and 4

Q: Which of the following is true about inheritance in Java?

1. Private methods are final. 2. Protected members are accessible within a package and inherited classes outside the package. 3. Protected methods are final. 4. We cannot override private methods. ANSWER = 1, 2, and 4

Q: With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?

1. x++; 2. x = x + 1; 3. x += 1; 4. x =+ 1; ANSWER: 1, 2, 3 & 4

Q: What is a Primary Key?

A key set on a column in a table that uniquely identifies a record.

Q: What is a primary key?

A key set on a column in a table that uniquely identifies a record. The key must be a unique value.

Q: What is a foreign key?

A primary key from its parent table that relates the two tables together.

Q: What is an identity column?

A special type of column in a table that automatically adds a numeric value to the record. The value is auto-incremented by the increment value for every new record inserted into the table.

Q: What does a Stored Procedure allow you to do?

A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again.

Q: What will be the output of the following Java code? public static void main(String args[]) { int x = 10; int y = 2; try { for (int z = 2; z >= 0; z--) { int ans = x / z; System.out.print(ans+ " "); } } catch (Exception e1) { System.out.println("Exception Encountered"); } catch (ArithmeticException e1) { System.out.println("Arithmetic Exception Encountered"); } }

ANSWER = Compilation Error

Q: What will be the output of the following Java code? public static void main(String args[]) { int var1 = 5; int var2 = 6; int var3; var3 = ++ var2 * var1 / var2 + var2; System.out.print(var3); }

ANSWER: 12

Q: What will be the output of the following Java code? class box { int width; int height; int length; } class main { public static void main(String args[]) { box obj = new box(); obj.width = 10; obj.height = 2; obj.length = 10; int x = obj.width * obj.height * obj.length; System.out.print(x); } }

ANSWER: 200

Q: What would be the output of the following code snippet if variable a=10? if(a<=0) { if(a==0) { System.out.println("1 "); } else { System.out.println("2 "); } } System.out.println("3 ");

ANSWER: 3

Q: What will be the output of the following Java code snippet? public static void main(String args[]) { ArrayLists obj = new ArrayLists() obj.add("A"); obj.add("B"); obj.add("C"); obj.add(1, "D"); System.out.print(obj); }

ANSWER: [A,D,B,C]

Q: What will be the output of the following Java code? public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); System.out.println(s) }

ANSWER: abc

Q: The EXISTS keyword will be true if ____________

Any row in the subquery meets the condition only

Q: What data structure should be used when the number of elements is fixed?

Array

Q: When does method overloading get determined?

At compile time Overloading is determined at compile time. Hence, it is also known as compile time polymorphism.

Q: What operator in the Where clause would you use to check for records from a range of dates?

BETWEEN

Q: Which of the following is a valid declaration of an object of class Box?

Box obj = new Box(); Wrong: obj = new Box(); Box obj = new Box; new Box obj;

Q: What does CRUD stand for?

C = Create R = Read / Retrieve U = Update D = Delete / Destroy

Q: If we want to eliminate duplicates, we use the keyword __________in the aggregate expression.

Distinct

Q: Which concept of Java is achieved by combining methods and attribute into a class?

Encapsulation Encapsulation is implemented by combining methods and attribute into a class. The class acts like a container of encapsulating properties.

Q: Match the 4 principles of OOP with their descriptions.

Encapsulation → Wrapping variables and methods together as a single unit. Inheritance → A class can be derived by using the attributes and methods from another class. Abstraction → The process of hiding certain details and showing only essential information to the user. Polymorphism → The ability of an object to take on many forms.

Q: Static members are not inherited to a subclass.

False

Q: What is a Non-Clustered Index?

Index structure separate from the data stored in a table that reorders one or more selected columns.

Q: What is a Clustered Index?

Index structure that confirms and guarantees that the index key doesn't contain any copy esteems and along these lines, empowers the clients to examine that each row in the table is exceptional in either way.

Q: What is a Clustered Index?

Indexes whose order of the rows in the data pages corresponds to the order of the rows in the index.

Q: What are the 4 types of joins?

Inner Join Right Outer Join Full Outer Join Left Outer Join

Q: Which of the following statements is true concerning subqueries?

Involves the use of an inner and outer query

Q: When would we want to de-normalize a database?

It typically occurs in applications that have to join across multiple tables or have complex joins and can't take the performance hit of joining the tables.

Q: When would we want to de-normalize a database?

It typically occurs in applications that have to join across multiple tables or have complex joins and can't take the performance hit of joining the tables. De-normalization of a database occurs for performance reasons only.

Q: What is a Foreign Key

It's a column in an entity referencing the primary key in another entity. Foreign Keys maintain referential integrity

Q: What type of join is needed when you wish to include rows that do not have matching values?

Outer join

Q: A lambda expression consists of two parts, the __________ part and the ________ part separated by a forward arrow

Parameter & Expressions

Q: Which of these can be used to differentiate two or more methods having the same name?

Parameters data type Number of parameters Return type of method

Q: To restrict a variable of a class from being inherited by a subclass, how should the variable be declared?

Private

Q: Match the definitions with the correct form of Polymorphism.

Provides the specific implementation of the method that is already provided by its superclass. → Method overriding, Increases the readability of the program → Method overloading, In this case, the parameters must be different → Method overloading, Occurs within the class → Method overloading, Occurs in two classes that have IS-A relationship between them. → Method overriding, In this case, the parameters must be the same. → Method overriding

Q: List the access modifiers from most accessible to least accessible.

Public Protected Default Private

Q: What does "Referential Integrity" mean?

Referential integrity requires that a record exists in the parent table before you can add a record in the child table.

Q: What is referential integrity?

Referential integrity requires that a record exists in the parent table before you can add a record in the child table.

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

SELECT * FROM Persons WHERE FirstName LIKE '%a'

Q: Which of the following should be used to find all the courses taught in the Fall 2009 semester but not in the Spring 2010 semester?

SELECT DISTINCT course id FROM SECTION WHERE semester = 'Fall' AND YEAR= 2009 AND course id NOT IN (SELECT course id FROM SECTION WHERE semester = 'Spring' AND YEAR= 2010);

Q: What SQL statement would you use to retrieve only 2 records from a table?

SELECT TOP 2

Q: What SQL statement would you use to retrieve only 2 records from a table?

Select Top 2

Q: Which of the following is an aggregate function?

Sum

Q: What is the purpose of the SQL AS clause?

The AS SQL clause is used to change the name of a column in the result set or to assign a name to a derived column

Q: What does the ISNULL function do?

The ISNULL() checks if the parameter passed in has a value and IS NOT null. If the parameter is null, then it updates itself to its current value.

Q: Which of these is the necessary condition for implicit type casting to occur?

The destination type is larger than source type

Q: What normal form are we trying to reach with our application?

Third normal form (3NF)

Q: All methods of an interface must be implemented.

True

Q: When a variable is declared as final, the value can't be modified. If a value has not been assigned to that variable, then it can be assigned only by the constructor of the class.

True

Q: What is the return type of a method that does not return any value?

Void

Q: Select * from employee where salary>10000 and dept_id=101;

Which of the following fields are displayed as output? All the field of employee relation

Q: What keyword do you use in the WHERE clause for a pattern/wildcard search?

You can use the Like keyword in conjunction with the % sign for a wildcard search.

Q: Which of these is correct way of inheriting class A by class B?

class B extends A {}

Q: Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?

continue

Q: What does CRUD stand for?

create read OR RETRIEVE update delete Or destroy

Q: Which of these keywords can be used to prevent Method overriding?

final To disallow a method from being overridden, specify final as a modifier at the start of its declaration. Methods declared as final cannot be overridden.

Q: What would be the most efficient data type would you assign to the column that's storing your age?

small int

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

try

Q: Which of these statements is incorrect about a Switch statement?

two case constants in the same switch can have identical values

Q: What data type would you assign to the column that's storing your first name?

varchar(50)


Conjuntos de estudio relacionados

STATS - CHAPTER 5 LEARNING CHECKS

View Set

Professional Scrum Master Open Assessment

View Set