What is the importance of finally block in exception handling ?
Correct Answer
A finally block will always be executed, whether or not an exception is actually thrown Even in the case where the catch statement is missing and an exception is thrown, the finally block will still be executed Last thing to mention is that the finally block is used to release resources like I/O buffers, database connections, etc
Technology problems
Search Results
1. Should a main() method be compulsorily declared in all java classes?
Correct Answer: Friends can be either functions or other classes The class grants friends unlimited access privileges * The declaration of the function should be preceded by the keyword 'friend' * The function definition will not use the keyword or the scope operator '::' Thus, a friend function is an ordinary function or a member of another class
4. What is the default return type of a function ?
Correct Answer: 1 We can operate majority of test cases, but importantly we can make use testing techniques such as Pair-wise testing to reduce combinations, and/or model based testing to plan user journeys to ensure major functionality of web application works or not 2 We can also use analytics to get insight into what users do on the website, which page is most popular and which feature is most used by the users
7. What is the difference between Tags and HTML Elements ?
Correct Answer: * HTML elements communicate with the Browser how to represent the text * HTML elements become HTML tags when enclosed within the angular brackets as "<>"
8. Explain static and dynamic memory allocation with an example each.
Correct Answer: When amount of memory to be allocated is known beforehand ie at the the time of compilation, it is known as Static Memory Allocation Once the memory is allocated statically, it cannot be deallocated during program run So it leads to wastage of storage space Example: int A[100]; When amount of memory to be allocated is not known beforehand, rather it is determined at the time of program run, it is called Dynamic Memory Allocation It leads to efficient utilization of storage space Example: cout << " Enter number of elements: "; cin >> N; int *A = new int[N]; // dynamic memory allocation
9. Why static methods cannot access non static variables or methods?
Correct Answer: A static method cannot access non static variables or methods because static methods doesnt need the object to be accessed So if a static method has non static variables or non static methods which has instantiated variables they will no be intialized since the object is not created and this could result in an error
Correct Answer: String Args (String []) is an array of parameters of type String In Java, 'args' contains the supplied command-line arguments as an array of String objects In other words, if you run your program as 'java MyProgram Hello World' then 'args' will contain ["Hello", "World"] When a java class is executed from the console, the main method is what is called