Search Suggest

Core Java - Interview Questions and Answers

31. What r checked and unchecked Exceptions ?

* Unchecked Exceptions are those which r not included in throws list and are derived from RuntimeException which are automatically available and are in java.lang.

* Checked Exceptions are those which cannot handle by itself.

32. What are the various states and methods of thread ?

States : Running, Ready to run, Suspended, Resumed, blocked and terminated.
Methods: getName, getPriority, isAlive, join, run, sleep, start.

Thread priorities are MIN_PRIORITY, MAX_PRIORITY, NORM_PRIORITY.

33. What is interprocess synchronization ? ( also called Monitor, Semaphore )

Consider a small box namely MONITOR that can hold only one thread. Once a thread enters a monitor, all other threads must wait until that thread exits the monitor.

In this way, a monitor can be used to protect a shared asset from being manipulated by more than one thread at a time.
Once a thread is inside a synchronized method, no other thread can call any other synchronized method on the same object.

34. What is Stream ?

It is an Abstraction that either produces or consumes information.
Two types : Byte Stream and Character Stream.
Print Writer is to Print output in Real World Programs.

35. How to enter data in java ?

First specify :

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
then say br.read(), and this is put in do while loop to receive as many as we require.

36. Define Inline Functions ?

In ordinary functions, during the program execution, at any function call the controller jumps to the function definition, performs operation and returns the value, then comes back to the program.

Whereas in Inline functions the controller copies the complete function definition into the program and performs operations.

37. What are the four components in URL ?

http:// www. yahoo .com : 8080 / index.html
http: --- > is protocol
www. yahoo .com ---à is IP address
8080 --à port number and is a pointer to memory location.
index.html --à file path to be loaded

38. What is a StringTokenizer ?

String Tokenizer provide parsing process in which it identifies the delimiters provided by the user , by default delimiters are spaces, tab, newline etc. and separates them from the tokens. Tokens are those which are separated by delimiters.

39. What are macros and Inline functions ? Which is best and Difference ?

Inline functions do Parameter passing, where as Macros do Text Substitution.
Its better to go for Inline functions than macros, else you may get different results.

40. What is a file ? What is a Directory ?

File : Describes the properties of file, like permissions, time, date, directory path, and to navigate subdirectory hierarchies.
Directory : Is a file that contains list of other files and directories .



إرسال تعليق