Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

The following code can be implemented to center text horizontally and vertically in a TextView:

*** android:id="@+id/textView"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="@strings/text"
/>***
4 years ago
If you want to abandon the use of a stored procedure for a user-defined function, then you can use an inline table-valued user-defined function. This is essentially a stored procedure (will take parameters) that returns a table as a result set; and therefore will place nicely with an INTO statement.

For example, there is an inline table-valued user-defined function to get a list of customers for a particular region:

***CREATE FUNCTION CustomersByRegion
(
@RegionID int
)
RETURNS TABLE
AS
RETURN
SELECT *
FROM customers
WHERE RegionID = @RegionID
GO***

Then, you can call this function to get what your results a such:
***SELECT * FROM CustomersbyRegion(1)***

Or to do a SELECT INTO:
***SELECT * INTO CustList FROM CustomersbyRegion(1)***

If still there is a need for a stored procedure, then wrap the function as below:
***CREATE PROCEDURE uspCustomersByRegion
(
@regionID int
)
AS
BEGIN
SELECT * FROM CustomersbyRegion(@regionID);
END
GO***
4 years ago
The following code can be implemented in SQL Server to UPDATE statement with JOIN:

***update u
set u.assid = s.assid
from ud u
inner join sale s on
u.id = s.udid***
4 years ago
The major difference between UNION ALL and UNION is that UNION ALL keeps all of the records from each of the original data sets including duplicates, whereas UNION only keeps the unique records.
4 years ago
The below code can be implemented to find all tables containing column with specified name in MS SQL :
***SELECT COLUMN_NAME AS 'ColumnName'
,TABLE_NAME AS 'TableName'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%MyName%'
ORDER BY TableName
,ColumnName;***
4 years ago
The explicit function specifier controls unwanted implicit type conversions. Basically, it tells the compiler that only explicit call to this constructor is allowed.
For example, if there is a buffer class whose constructor **Buffer(int size)** takes the size of the buffer in bytes, and you don't want the compiler to quietly turn **int** s into **Buffer**s. So to prevent that, you declare the constructor with the **explicit** keyword:
***class Buffer
{
explicit Buffer(int size);
...
}***

That way,
***void useBuffer(Buffer& buf);
useBuffer(4);***
becomes a compile-time error. If you want to pass a temporary **Buffer** object, then do the following
***useBuffer(Buffer(4));***
This will prevent the compiler from surprising you with unexpected conversions.
4 years ago
This kind of error generally occurs when you try to import a module thinking of it as a function and call it. So in Python, a module is a .py file. Packages(directories) can also be considered as modules.
Suppose there is a *create.py* file. In that file there is a function like this:
***#inside create.py
def create():
pass***

Now there is another code like:
***#inside main.py file
import create
create()***
Here, create refers to create.py, so create.create() would work here.

But it will give an error if the create.py is called as a function. So, to overcome this situation we have to do the following
***from create import create
create()***
4 years ago
If you are using Android Studio and you are facing this issue then the best way to solve this problem will be by checking which platform tool is missing. In order to do this, first, click on 'Tools' present on the top tab bar of android studio. Then, select Android and then select the SDK Manager. Now, click on the Launch Standalone SDK manager. You can clearly see which platform tool is missing. So just install that and then your adb will start working properly.
4 years ago
Java is strictly pass by value. This is because in java the method parameter values are copied to another variable and then the copied object is passed.
4 years ago
Strings are immutable in nature which means it cannot be altered once they have been created. Moreover, strings are stored in the heap memory or String pool and remains in memory for a long duration, which poses a security threat. Whereas char[] are mutable in nature which means its content can be erased or modified once its purpose is served. When it's done being used it is cleaned and no one could ever know about the information you had stored. So, for security reasons char[] preferred over String for passwords in Java
4 years ago
The keywords public, protected, default, and private are called the access modifiers. These access modifiers determines the scope of the classes, interfaces, variables, methods, constructors, data members, and the setter methods.
If the access modifier is *public*,then it is accessible by all the classes.
If the access modifier is *protected*,then it is accessible by all the classes in the same package and within sub-classes in other packages(through inheritance).
If the access modifier is *default*,then it is accessible by all the classes in the same package.
If the access modifier is *private*,then it is accessible within the same class as it is declared.
4 years ago
The difference between the above two is that for malloc only one argument is taken i.e., the number of bytes to be allocated whereas in calloc two arguments are taken. The first argument is for the number of blocks of memory to be allocated and the second argument is for the number of bytes to be allocated at each block of memory.
The use of calloc and malloc entirely depends on the requirement. For example, If there is a requirement to initialize the allocated memory by zero, then calloc is used over malloc. Whereas malloc is used over calloc as it is faster.
4 years ago