Mastek Java Questions: Java Basics
Download PDF of This Page (Size: 111K) ↧
Examrace Placement Series prepares you for the toughest placement exams to top companies.
-
The Java interpreter is used for the execution of the source code. True False Ans: a
-
On successful compilation a file with the class extension is created.
-
True
-
False
Ans: a
-
-
The Java source code can be created in a Notepad editor.
-
True
-
False
Ans: a
-
-
The Java Program is enclosed in a class definition.
-
True
-
False
Ans: a
-
-
What declarations are required for every Java application? Ans: A class and the main () method declarations.
-
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.
-
What are the three OOPs principles and define them? Ans: Encapsulation, Inheritance and Polymorphism are the three OOPs Principles. Encapsulation: Is the Mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. Inheritance: Is the process by which one object acquires the properties of another object. Polymorphism: Is a feature that allows one interface to be used for a general class of actions.
-
What is a compilation unit? Ans: Java source code file.
-
What output is displayed as the result of executing the following statement? System. Out. Println ( “//Looks like a comment.” );//Looks like a comment The statement results in a compilation error Looks like a comment No output is displayed Ans: a
-
In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true? It must have a package statement It must be named Test. Java It must import java. Lang It must declare a public class named Test Ans: b
-
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.
-
What is the return type of program's main () method? Ans: Void
-
What is the argument type of program's main () method? Ans: String array
-
Which characters are as first characters of an identifier? Ans: A Z, a z, _, $
-
What are different comments? Ans://--single line comment/* -- */multiple line comment/* * -- */documentation
-
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.
-
What is the use of bin and lib in JDK?
Ans: Bin contains all tools such as javac, applet viewer, awt tool etc. whereas Lib contains all packages and variables.