1.What is a static method?
Ans: A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated.
2.What is a protected method?
Ans: A protected method is a method that can be accessed by any method in its package and inherited by any subclass of its class.
3.What is the difference between a static and a non-static inner class?
Ans: A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.
4.What is the purpose of the System class?
Ans: The purpose of the System class is to provide access to system resources.
5.What is the purpose of the finally clause of a try-catch-finally statement?
Ans: The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.
6.What is difference between Path and Classpath?
Ans: Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.
7.What is thread?
Ans: A thread is an independent path of execution in a system.
8.What is multi-threading?
Ans: Multi-threading means various threads that run in a system.
9.How does multi-threading take place on a computer with a single CPU?
Ans: The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
10.How to create a thread in a program?
Ans: You have two ways to do so. First, making your class "extends" Thread class. Second, making your class "implements" Runnable interface. Put jobs in a run() method and call start() method to start the thread.
11.How can we tell what state a thread is in ?
Ans: Prior to Java 5, isAlive() was commonly used to test a threads state. If isAlive() returned false the thread was either new or terminated but there was simply no way to differentiate between the two.
Starting with the release of Tiger (Java 5) you can now get what state a thread is in by using the getState() method which returns an Enum of Thread.States.
Ans: A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated.
2.What is a protected method?
Ans: A protected method is a method that can be accessed by any method in its package and inherited by any subclass of its class.
3.What is the difference between a static and a non-static inner class?
Ans: A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.
4.What is the purpose of the System class?
Ans: The purpose of the System class is to provide access to system resources.
5.What is the purpose of the finally clause of a try-catch-finally statement?
Ans: The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.
6.What is difference between Path and Classpath?
Ans: Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.
7.What is thread?
Ans: A thread is an independent path of execution in a system.
8.What is multi-threading?
Ans: Multi-threading means various threads that run in a system.
9.How does multi-threading take place on a computer with a single CPU?
Ans: The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
10.How to create a thread in a program?
Ans: You have two ways to do so. First, making your class "extends" Thread class. Second, making your class "implements" Runnable interface. Put jobs in a run() method and call start() method to start the thread.
11.How can we tell what state a thread is in ?
Ans: Prior to Java 5, isAlive() was commonly used to test a threads state. If isAlive() returned false the thread was either new or terminated but there was simply no way to differentiate between the two.
Starting with the release of Tiger (Java 5) you can now get what state a thread is in by using the getState() method which returns an Enum of Thread.States.
Previous | Next |
:: Click the links below for similar type Questions and answers ::
0 comments:
Post a Comment