answersLogoWhite

0

📱

Java Programming

The Java programming language was released in 1995 as a core component of the Java platform of Sun Microsystems. It is a general-purpose, class-based, object-oriented language that is widely used in application software and web applications.

5,203 Questions

Sample Sql query with explanation for selecting the alternate row from the table?

SELECT *

FROM ( SELECT FirstName LastName

FROM people

) @tempTable1

WHERE MOD(@temptable1.rn 2) 1

--even number query

SELECT *

FROM ( SELECT rownum rn firstname lastname

FROM people

) @temptable1

WHERE MOD(@temptable1.rn 3) 0

but it is not working properly...can anubody tell me what is rownum here...

What is fd fan api standard?

The FD Fan API standard refers to a specification designed to facilitate communication between fan controllers and various applications in industrial environments. It provides a consistent framework for monitoring and controlling fan operations, enabling features like speed adjustment, performance monitoring, and fault detection. This standard helps improve interoperability among different devices and systems, enhancing overall efficiency and reliability in fan management.

How do you delete and recreate a service?

If u r asking how to delete and recreate a Microsoft service, then the following would help u.

Note: take a backup of the registry before attempting these steps.

from services.msc doubleclick on the service you want to delete and find the service name

from the cmd console, type

///sc delete <servicename>

deleted service

check with services.msc you will find it disabled.

now type,

/// reg copy hklm\system\ControlSet001\services\<servicename> hklm\system\CurrentControlSet\services

operation completed successfully

restart the machine.

or

you can export the registry,delete the key using SC command and restart the PC and merge the backup.

Disclaimer: Try this at your own risk

What does 'public static final int' mean?

public: It can be called (method) or accessed (field) from any class in any package.

static: It is declared on the class rather than the object. If a method, you do not need an object to call it, it can be called directly on the class. If a field, there is only one variable for the class, not one per object.

final: If a method, the method cannot be overridden. If a field, the value cannot be changed (a constant).

int: If a method, the return type. If a field, the field type (it can only hold values of type 'int'). int is the primitive integer type.

Is duplicated data is accepted in linked list?

Yes definitely, a linked list can accept duplicate data. As the data of each node does not have any concern with data of other node. The node differs from each other in their addresses. Until user does not make the linked list to accept unique data, the linked list can accept duplicates.

if unsorted (e.g. representig a queue): yes

if sorted (e.g. representing a set): should be decided design-time

How do you delete all table in a database?

Unless you want to drop (delete) the entire database, you will must delete tables individually.

To delete tables individually, execute the query "SHOW TABLES" in your database which will return a list of all table names. Iterate through that resultset and execute "DROP TABLE {$table_name}"

If a method calls another method and that method throw an exception then caller method must be throw that exception or not?

If method A calls method B and method B throws an exception, then method A must handle that exception. It does not have to throw the exception if it is in a try-catch block, but it must do something to deal with it.

Note that this only applies to checked exceptions. If method B throws an unchecked exception, then A is allowed to ignore it.

How do you remove recursion using stacks?

Using stacks won't remove recursion, they can only re-implement those recursions. In some cases we don't actually need a stack to implement a recursive algorithm, in which case an iterative implementation will typically perform better with little to no cost in additional memory. But if we require a stack in order to implement recursions iteratively, then we pay the cost in terms of additional memory consumption (the "built-in" call stack is fixed-size and exists whether we use it or not). In addition, there may be a performance cost if we cannot determine how much additional memory we need.

As an example, consider the recursive quicksort algorithm:

template<typename T>using iter = std::vector<T>::iterator; template<typename T>void quicksort (iter begin, iter end) {

if (begin<end) {

size_t pivot = partition (begin, end);

quicksort (begin, pivot - 1);

quicksort (pivot + 1, end);

} // end if

}

Note that the partition algorithm is not shown for the sake of brevity. However, it is best implemented as a separate function as its local variables play no part in the recursion.

Being a divide-and-conquer algorithm, this algorithm requires a stack for back-tracking. Here is the iterative equivalent using a stack:

template<typename T>using iter = std::vector<T>::iterator;

template<typename T>void quicksort (iter begin, iter end) {

if (begin<end) {

std::stack<std::pair<iter, iter>> s {};

s.push ({begin, end});

while (s.empty() == false) {

begin = s.top().first();

end = s.top().second();

s.pop();

size_t pivot = partition (begin, end);

if (pivot + 1<end) s.push ({pivot + 1, end});

if (begin<pivot - 1) s.push ({begin, pivot - 1});

} // end while

} // end if

}

Note that the order we push the pairs on at the end of the while loop is the reverse order we wish them to be processed. The order doesn't actually matter, but it ensures both algorithms operate in a consistent manner, with depth-first traversal from left to right.

This implementation is naive because each push allocates new memory for each pair object we push onto the stack, releasing the same memory with each pop. Allocating and releasing system memory on a per-element basis like this is highly inefficient, so it's highly unlikely that this version will perform any better than the recursive algorithm.

However, the quicksort algorithm guarantees that there can never be more elements on the stack than there are elements in the initial range, so we can improve performance significantly by reserving sufficient memory in advance:

template<typename T>using iter = std::vector<T>::iterator;

template<typename T>void quicksort (iter begin, iter end) {

if (begin<end) {

std::vector<std::pair<iter, iter>> v {};

v.reserve (end - begin);

v.emplace_back (begin, end);

while (v.empty() == false) {

begin = v.back().first();

end = v.back().second();

v.pop_back();

size_t pivot = partition (begin, end);

if (begin < pivot - 1) v.emplace_back (begin, pivot - 1);

if (pivot + 1 < end) v.emplace_back (pivot + 1, end);

} // end while

} // end if

}

Note that in this implementation we use a vector rather than a stack, however all pops and pushes (implemented as emplace_back operations) occur at the back of the vector where the unused elements are, and that's precisely how an efficient stack should be implemented. As a result, this version will perform significantly better than the previous version and should perform at least as well as the recursive implementation if not better. The only significant cost is the cost of reserving memory in the vector.

What is the use of passing an argument by value?

Passing an argument by value means that the method that receives the argument can not change the value of the argument. Passing an argument by reference means that the method that receives the argument can change the value of the incoming argument, and the argument may be changed in the orignal calling method.

What is pallendrome in java?

palindrome in every language means same. it means on reversing a number or string, if we get the same number or string as the case may be ,then the number or string is called palindrome. eg: 1221,111,252 or LIRIL,MADAM etc .

What is embedding java script?

To embed JavaScript code is to include it in the HTML page. For example, this will embed the code to display an alert:

<script type="text/javascript">

alert("Embedded alert!");

</script>

How do you accept an integer or a float or double value as a console input from user in java also you do not want to use command line arguments?

Scanner scan = new Scanner(System.in); // A scanner object that reads from the

// keyboard( System.in), must import

//Scanner class to use this System.out.print("Input Integer: "); int first = scan.nextInt(); //Reads the next int after the printed stuff that the user

//inputs System.out.print("Input Double: "); double first = scan.nextDouble(); //Reads the next double after the printed stuff that

//the user inputs

How do you calculate size of an unsized array?

In Java, all arrays have a finite size. Even if you did not initialize an array to a particular size (say the array was being passed into a method), some other part of the program did. Because of this, the length of an array can always be accessed via the .length parameter.

Example:

int[] arr = new int[5];

System.out.print(arr.length); //5

public void k(int[] arr)

{

System.out.print(arr.length) //arr will always have a finite size

}

Why ostream operators not overloaded using member functions?

Consider the following line:

cout<<obj;

where obj is the object of Demo class.

In this case we are overloading "<<" operator. But overloading the binary

operator using member function, the left hand operand should be the object of relevant class.

Here in this case left hand side operand is not the object of Demo class. It is object of ostream class.

Hence we cant overload ostream operators using member function. But we can overload these type of operators using friend functions.

Thanks,

Prof. D. H. Ingole

What is Quadruple Power?

quadruple means anything that has 4 of something in it. quad=4

How many types of Data Base in market?

In many cases, each company has its own database (or several databases), so I would estimate that there are about as many databases as there are companies.

If you are referring to the DBMS - the software that manages the databases - you can see a list of the most common ones in the following Wikipedia articles:

* Comparison of relational database management systems

* Comparison of object database management systems

* Comparison of object-relational database management systems

Class limits and class boundaries?

The extreme values of a Class (Class - A range of values which incorporate a set of terms.) are called its Class Limits. This means that the Class doesn't contain values beyond the two extremes of its limits.

.....will be automatically Invoked when an object is created?

The Class object is automatically created by the JVM when an object is created. The Class object provides information about the Class and is primarily used by the IDEs and factory classes.

The method that is automatically called when an object is created is called a constructor. In Java, the constructor is a method that has the same name as the class.

How do you make a UIPickerView that plays sounds?

The UIPickerView doesn't actually play the sounds; you do that with a hidden media control. When you click the control button, you examine the selected element in the list and load the associated sound file into the media control, which then plays the file. There are various ways of doing it, but one of the simplest methods is to use two parallel arrays, one containing the titles (which you load into the list), the other containing the paths to the sound files. Both arrays being of type std::string, of course. Thus element 9 in the titles array maps to element 9 in the sound files array. Alternatively, use std::pair objects (where each element in the pair is a std::string) to associate each title with its sound file.

Why do you need to override the toString method?

By default every class you write inherently extends the base Object class. This has a basic toString() method which merely returns the name of the class followed by a hex representation of the hash value. By overriding this method, you can return a more meaningful value specific to your class, such as member attributes and their values.