|OCJP Certification Sample Question Set-2|
OCJP Certification Sample Question Set-2:
I have collected these information from different forums…
Hope this will help the test engineers to get knowledge on java to test it better..
1.The Java interpreter is used for the execution of the source code.
2) On successful compilation a file with the class extension is created.
3) The Java source code can be created in a Notepad editor.
4) The Java Program is enclosed in a class definition.
5) What declarations are required for every Java application?
Ans: A class and the main( ) method declarations.
6) What are the two parts in executing a Java program and their purposes?
Ans: Two parts in executing a Java program are:
Java Compiler and Java Interpreter.
The Java Compiler is used for compilation and the Java Interpreter is used for execution of the application.
7) What are the three OOPs principles and define them?
Ans : Encapsulation, Inheritance and Polymorphism are the three OOPs
Is the Mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
Is the process by which one object acquires the properties of another object.
Is a feature that allows one interface to be used for a general class of actions.
8) What is a compilation unit?
Ans : Java source code file.
9) What output is displayed as the result of executing the following statement?
System.out.println(“// Looks like a comment.”);
a.// Looks like a comment
b.The statement results in a compilation error
c. Looks like a comment
d. No output is displayed
Ans : a.
10) In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?
a. It must have a package statement
b. It must be named Test.java
c. It must import java.lang
d. It must declare a public class named Test
Ans : b
11) What are identifiers and what is naming convention?
Ans : Identifiers are used for class names, method names and variable names. An identifier may be any descriptive sequence of upper case & lower case letters,numbers or underscore or dollar sign and must not begin with numbers.
12) What is the return type of program’s main( ) method?
Ans : void
13) What is the argument type of program’s main( ) method?
Ans : string array.
14) Which characters are as first characters of an identifier?
Ans : A – Z, a – z, _ ,$
15) What are different comments?
Ans : 1) // — single line comment
2) /* —
*/ multiple line comment
3) /** —
16) What is the difference between constructor method and method?
Ans : Constructor will be automatically invoked when an object is created. Whereas method has to be call explicitly.
17) What is the use of bin and lib in JDK?
Ans : Bin contains all binary executable files…tools such as javac, applet viewer, awt tool etc., whereas Libcontains all packages and variables.