What does the “abstract” keyword mean in front of a method? A class?
Abstract keyword declares either a method or a class. If a method has a abstract keyword in front of it,it is called abstract method.Abstract method has no body.It has only arguments and return type.Abstract methods act as placeholder methods that are implemented in the subclasses.
Abstract classes can’t be instantiated.If a class is declared as abstract,no objects of that class can be created.If a class contains any abstract method it must be declared as abstract
What is JDBC? Describe the steps needed to execute a SQL query using JDBC.
The JDBC is a pure Java API used to execute SQL statements. It provides a set of classes and interfaces that can be used by developers to write database applications.
The steps needed to execute a SQL query using JDBC:
1. Open a connection to the database.
2. Execute a SQL statement.
3. Process th results.
4. Close the connection to the database.
What are native methods? How do you use them?
Native methods are methods that are defined as public static methods within a java class, but whose implementation is provided in another programming language such as C.
What does the keyword “synchronize” mean in java. When do you use it? What are the
Synchronize is used when u want to make ur methods thread safe. The disadvantage of synchronise is it will end up in slowing down the program. Also if not handled properly it will end up in dead lock.
1. Only use (and minimize it’s use)synchronization when writing multithreaded code as there is a speed (up to five to six time slower, depending on the execution time of the synchronized/non-synchronized method ) cost associated with its use.
2. In case of syncronized method modifier, the byte code generated is the exact same as non-syncronized method. The only difference is that a flag called ACC_SYNCRONIZED property flag in method’s method_info structure is set if the syncronized method modifier is present.
3. Also, syncronized keyword can make the code larger in size if used in the body of the method as bytecode for monitorenter/monitorexit is generated in addition to any exception handling.
Java says “write once, run anywhere”. What are some ways this isn’t quite true?
Any time you use system calls specific to one operating system and do not create alternative calls for another operating system, your program will not function correctly.
Solaris systems and Intel systems order the bits of an integer differently. (You may have heard of little endian vs. big endian)
If your code uses bit shifting, or other binary operators, they will not work on systems that have opposide endianism