Quiz
Question 1
What is the output of the following Java program? Please assume all classes are in the same package.
[ ] requirement analysis design development testing implementation maintenance
[x] sdlc
[ ] Compile time error
[ ] Runtime error
[ ] rddtim
Question 2
What is the extension of Java source code files?
[ ] .jar
[x] .java
[ ] .class
[ ] .jv
Question 3
What is the output of the following Java program?
[ ] 1 2 3 4 5 6 7 8 9
[ ] 2 4 6 8
[x] 1 3 5 7 9
[ ] 1 3 5 7
Question 4
A class declares three methods with the same name as shown. Is this a valid example of method overloading? Assume that Fuel is a class defined in the same package.
[x] True
[ ] False
Question 5
What is the output of the following program? Assume that each class is correctly declared in its own file and that the main method of Chemistry is the JVM entry point. Please assume all classes are in the same package.
[ ] The program will not compile because Iodine is not an Element.
[ ] OVERRIDE THIS METHOD lustrous, purple-black non-metallic solid
[ ] OVERRIDE THIS METHOD
[x] lustrous, purple-black non-metallic solid
Question 6
Given these code snippets:
Is the following assignment valid?
[ ] YES
[x] NO
Question 7
What is Polymorphism In object-oriented programing?
[ ] A process that binds together the data and functions that manipulate the data and that keeps both safe from outside interference and misuse.
[x] Refers to the ability of a variable, function or object to take on multiple forms
[ ] An ability by which one class acquires the properties and behaviors of another class
[ ] Process of hiding the implementation details from the user, only the functionality will be provided to the user. In other words, the user will have the information on what the object does instead of how it does it.
Question 8
______________ can be declared anywhere within the class definition, but by convention, they are declared near the top of the class definition.
[ ] Temporary variable
[ ] Local variable
[ ] None of the mentioned
[x] Class variable
Question 9
Which keyword(s) can be part of a class declaration? (check all that are correct)
[ ] switch
[x] class
[x] extends
[x] implements
[ ] extend
Question 10
In Java, what is the difference between the String Class and the StringBuffer Class?
[ ] A StringBuffer is immutable, if you try to alter its value, another object gets created. A String is mutable so it can change its value.
[ ] No difference, the two classes are equivalent.
[ ] StringBuffer is the parent/super case of String.
[x] A String is immutable, if you try to alter its value, another object gets created. A StringBuffer is mutable so it can change its value.
Question 11
What is Truncation for numeric variables in Java?
[x] Floating-point value assigned to an integer type
[ ] Integer value assigned to floating type
[ ] Floating-point value assigned to an Floating type
[ ] None of the Mentioned
Question 12
What is the return type of Constructors?...
[ ] int
[x] No explicit return type
[ ] float
[ ] void
Question 13
Which of the following best describes the meaning of static?
[x] The static keyword can be applied to class members. This implies that the class members (static ones) belong to the class, not to instances of the class.
[ ] The static keyword, when applied to fields, means that the field can only be accessed through instances of the class.
[ ] When applied to a class, the static keyword implies that instances of the class are immutable.
[ ] The static keyword can be applied to local variables. This implies that their values persist between calls to the method that declares the variable.
Question 14
What is Autoboxing?
[ ] when an object of a wrapper class is automatically converted to its matching primitive value
[ ] A mechanism of Abstraction
[x] when a primitive value is automatically converted to its matching wrapper class object
[ ] A mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit
Question 15
What data type would you use to store the names of students?
[ ] int
[ ] boolean
[ ] char
[x] String
Question 16
What is Inheritance in Object-Oriented Programming?
[ ] A process that binds together the data and functions that manipulate the data and that keeps both safe from outside interference and misuse.
[ ] Refers to the ability of a variable, function or object to take on multiple forms
[ ] Process of hiding the implementation details from the user, only the functionality will be provided to the user. In other words, the user will have the information on what the object does instead of how it does it.
[x] An ability by which one class acquires the properties and behaviors of another class
Question 17
Which of these is an invalid Array declaration?
[x] int[] arr = new int[];
[ ] int[] arr = new int[5];
[ ] None of the mentioned
[ ] int[] arr; arr = new int[5];
Question 18
The fields/variables in an interface are implicitly specified as -
[ ] static only
[ ] final only
[x] static and final
[ ] Integer
Question 19
What is the process of defining more than one method in a class differentiated by method signature?
[ ] Method Overwriting
[ ] Method Overlapping
[ ] Method Overriding
[x] Method Overloading
Question 20
How many copies of static (class) variables and instance variables are created when 10 objects are created of a class?
[ ] 1,1
[ ] 10, 10
[ ] 10,1
[x] 1, 10
Question 21
Which of these statements is incorrect?
[x] Interfaces can be instantiated
[ ] Interfaces cannot have constructors.
[ ] Abstrac classes can have constructors.
[ ] Abstract classes may or may not have abstract methods.
Question 22
What is the output of the following Java program? Please assume all classes are in the same package.
[ ] mySQLSqoophdfs
[ ] extraction1transformation2loading3
[x] EXTRACTION1TRANSFORMATION2LOADING3
[ ] EXTRACTION1 TRANSFORMATION2 LOADING3
Question 23
A method declaration has (check all that are correct):
[x] A name
[ ] At least one parameter
[x] A return-type, or void if no value is returned.
[x] An optional access specifier which, if not present, defaults to package access.
[x] Parentheses () - with or without a parameter list.
Question 24
Which of the below is an invalid identifier with the main() method?
[x] private
[ ] static
[ ] final
[ ] public
Question 25
What is the output of the following Java program? Please assume all classes are in the same package.
[ ] None of the mentioned
[ ] extraction transformation loading
[x] Compile time error
[ ] loading transformation extraction
[ ] Runtime error
Question 26
If a class of a Java program has a plural number of methods, and all of them have the same name but different parameters (with a change in type or number of arguments), then it is known as method overloading.
[x] True
[ ] False
Question 27
Which of the following modifier means a particular variable cannot be accessed from other class even within the same package?
[ ] default
[ ] protected
[ ] public
[x] private
Question 28
Variables, methods, and constructors, which are declared protected in a superclass can be accessed only by the subclasses in other packages or any class within the package of the protected members' class.
[x] True
[ ] False
Question 29
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
[ ] for
[ ] None of the above
[x] do-while
[ ] while
Question 30
Which of the following is a valid declaration of an object of class Box?
[ ] Box new obj;
[x] Box obj = new Box();
[ ] obj = new Box();
[ ] Box obj = new Box;
Last updated