java ôn tập
java ôn tập
The correct answer is: JVM converts Source Code to Byte Code
The correct answer is: JVM converts Source Code to Byte Code
/
Question 3 The ___ is entry point of Java program.
Not answered
Select one:
Marked out of 1.00
a. instance method
b. static method
c. main method
d. class method
c. class method
d. instance method
c. platform
d. javac tool
/
Question 6 A ___ is the hardware or software environment in which a program runs.
Not answered
Select one:
Marked out of 1.00
a. JVM
b. javac tool
c. platform
d. JRE
The correct answer is: JVM, the java application programming interface (API)
The correct answer is: JVM, the java application programming interface (API)
/
Question 9 Which of the following concept does not belong to object oriented programming features?
Not answered
Select one:
Marked out of 1.00
a. Inheritance
b. Polymorphism
c. Encapsulation
d. Cross-platform
c. include
d. interface
/
Question 12 Choose a right statement about javac tool.
Not answered
Select one:
Marked out of 1.00
a. javac tool is used to run JVM
b. The compiler converts the high-level into a format understood by the machines.
c. javac tool is used to run java application.
d. javac tool compiles class and interface definitions into bytecode class files.
The correct answer is: javac tool compiles class and interface definitions into bytecode class
files.
Question 13 A java source code is a file with the file extension is …….
Not answered
Select one:
Marked out of 1.00
a. .java
b. .class
c. .jar
d. .rar
Question 14 A java source code is a file with the file extension is …….
Not answered
Select one:
Marked out of 1.00
a. .class
b. .rar
c. .jar
d. .java
/
Question 15 A Java source code will be compiled to the file with file extension is ……
Not answered
Select one:
Marked out of 1.00
a. .bat
b. .java
c. .class
d. .exe
Question 16 A Java source code will be compiled to the file with file extension is ……
Not answered
Select one:
Marked out of 1.00
a. .bat
b. .java
c. .class
d. .exe
The correct answer is: It is the ability for a message/data to be processed in more than one
form.
/
Question 18 Which of the following is the best description about polymorphism ?
Not answered
Select one:
Marked out of 1.00
a. It is the ability for a message/data to be processed in more than one form.
The correct answer is: It is the ability for a message/data to be processed in more than one
form.
/
Question 21 Choose a primitive datatype in Java.
Not answered
Select one:
Marked out of 1.00
a. String
b. Date
c. char
d. Integer
b. Interface
c. Array
d. boolean
Question 23 assume that all lib files are imported. What is the output of the code?
Not answered public static void main(String[] args){
Marked out of 1.00 Date a=new Date();
boolean result=a instanceof Date
System.out.print("a is instance of :"+result);
}
Select one:
a. a is instance of : false
b. a is instance of : Calendar
c. a is instance of : true
d. a is instance of : Object
/
Question 24 consider the code:
Not answered public static void main(String[] args) {
Select one:
a. 8
b. 9
c. 6
d. 11
Select one:
a. 8
b. 6
c. 9
d. 11
/
Question 26 Basic primitive types may include_____
Not answered
Select one:
Marked out of 1.00
a. Scanner, System, Math, File
The correct answer is: char, int, long, float, double, boolean
Question 27 Which statement is used to store a big long number, e.g. 5 billion?
Not answered
Select one:
Marked out of 1.00
a. int n = 5000000000;
b. int n = 5b;
c. long n = 5000000000;
d. long n = 5_000_000_000L;
b. “c”
c. “char”
d. ‘char’
/
Question 29 Which of the following belongs to the type of character?
Not answered
Select one:
Marked out of 1.00
a. “char”
b. ‘char’
c. ‘c’
d. “c”
b. int n = FACE;
c. int = hexFACE;
d. int n = 0xFACE;
Question 31 Suppose that a and b are single dimensional arrays of integers, index1 and index2 are valid
Not answered indexes. Study the following statements:
Select one:
a. Both (1) and (2) are not accepted.
The correct answer is: Both (1) and (2) are accepted.
/
Question 32 Select a correct Java declaration.
Not answered
Select one:
Marked out of 1.00
a. int $myInt;
b. int !cash;
c. int 3money;
d. int interface;
Question 33 Which of the following can be used to access the second element of an array named
Not answered arrOne?
c. arrOne[2]
d. arrOne[1]
d. class ParserNum {}
/
Question 35 Choose the valid array declaration in java.
Not answered
Select one:
Marked out of 1.00
a. char[3] myArray;
b. char myArray[3]=['a','b','c'];
c. char[] myArray;
d. char myArray={'a','b','c'};
e. char myArray[3];
Question 36 Which of following operator is used to allocate memory to array variable in Java?
Not answered
Select one:
Marked out of 1.00
a. new malloc
b. calloc
c. new
d. malloc
/
Question 38 State of a software object is ____
Not answered
Select one:
Marked out of 1.00
a. memory block was allocated
b. properties
c. methods
b. properties
c. fields
/
Question 41 The keyword ____ is used to declare a subclass.
Not answered
Select one:
Marked out of 1.00
a. extension
b. extend
c. extends
d. expands
b. expands
c. extend
d. extends
Question 43 _____ is a way to group related classes in Java and it is called as a namespace also.
Not answered
Select one:
Marked out of 1.00
a. software
b. folder
c. file
d. package
/
Question 44 _____ of OOP supports ability to hide information.
Not answered
Select one:
Marked out of 1.00
a. polymorphism
b. inheritance
c. encapsulation
d. grouping
Question 45 The modifier ____ is a way to hide information of a class from outside world.
Not answered
Select one:
Marked out of 1.00
a. protected
b. public
c. default
d. private
/
Question 47 Common access modifiers are
Not answered
Select one:
Marked out of 1.00
a. public, final, static, protected, default, private
Question 48 Assume that all library files are imported. Study the following code:
Not answered public class Test {
Select one:
a. A30B
b. AB30
c. Compile-time error
d. B30A
/
Question 49 Assume that all lib files are imported. Study the following code:
Not answered public class Test {
Marked out of 1.00 void f() {
System.out.print(1);
}
}
class Test2 extends Test {
void f() {
System.out.print(2);
}
}
class Program {
public static void main (String[] args) {
Test obj = new Test2();
obj.f();
}
}
What is it's result?
Select one:
a. 2
b. Compile-time error
c. 1
d. 12
e. 21
/
Question 50 Assume that all lib files are imported. Study the following Java code:
Not answered public final class Test {
Marked out of 1.00 void f() {
System.out.print(1);
}
}
class Test2 extends Test {
void f() {
System.out.print(2);
}
}
class Program {
public static void main (String[] args){
Test obj = new Test2();
obj.f();
}
}
What is it's result?
Select one:
a. 1
b. Compile-time error
c. 2
d. 3
/
Question 51 Assume that all lib files are imported. Study the following Java code:
Not answered public final class Test {
Marked out of 1.00 void f() {
System.out.print(1);
}
}
class Test2 extends Test {
void f() {
System.out.print(2);
}
}
class Program {
public static void main (String[] args){
Test obj = new Test2();
obj.f();
}
}
What is it's result?
Select one:
a. 2
b. 1
c. Compile-time error
d. 3
/
Question 52 Study the following code:
Not answered public class Test {
Marked out of 1.00 int x= 5;
int y=2;
public static void main (String[] args){
Test obj;
obj.x=10;
obj.y=20;
System.out.println(obj.x + obj.y);
}
}
What is output?
Select one:
a. Error
b. 7
c. 30
d. 90
Question 53 Hiding internal data from the outside world, and accessing it only through publicly exposed
Not answered methods is known as data .........
c. aggregation
d. grouping
/
Question 54 Choose a proper option to fill up blanks.
Not answered statement 1: A software object's state is stored in ____.
Marked out of 1.00 Statement 2: A software object's behavior is exposed through ______.
Select one:
a. methods, fields
b. fields, background
c. functions, methods
d. fields, methods
Select one:
a. functions, methods
b. fields, methods
c. fields, background
d. methods, fields
/
Question 56 What is the output from the following code?
Not answered class NumberHolder {
Marked out of 1.00 public int anInt;
public float aFloat;
}
public class Main {
public static void main(String[] args) {
NumberHolder aNumberHolder;
aNumberHolder.anInt = 1;
aNumberHolder.aFloat = 2.3f;
System.out.print(aNumberHolder.anInt);
System.out.print(aNumberHolder.aFloat);
}
}
Select one:
a. 12.3f
b. Error
c. 12.3
d. 3.3
/
Question 57 What is the output from the following code?
Not answered class NumberHolder {
Marked out of 1.00 public int anInt;
public float aFloat;
}
public class Main {
public static void main(String[] args) {
NumberHolder aNumberHolder;
aNumberHolder.anInt = 1;
aNumberHolder.aFloat = 2.3f;
System.out.print(aNumberHolder.anInt);
System.out.print(aNumberHolder.aFloat);
}
}
Select one:
a. 12.3
b. Error
c. 12.3f
d. 3.3
Question 58 Object-oriented programming allows classes to ____ commonly used state and behavior
Not answered from other classes. In Java, the ____ keyword is used to declare a subclass of another
class.
Marked out of 1.00
Select one:
a. have, extend
b. use, extends
c. inherit, extends
d. use, implements
/
Question 59 Object-oriented programming allows classes to ____ commonly used state and behavior
Not answered from other classes. In Java, the ____ keyword is used to declare a subclass of another
class.
Marked out of 1.00
Select one:
a. use, extends
b. inherit, extends
c. use, implements
d. have, extend
c. local variable
d. object reference
/
Question 61 Given the following class definition
Not answered public class Dog {
Marked out of 1.00 private String name;
//constructor…
Select one:
a. newName = name;
b. this.name = newName;
c. name == newName;
d. name = this.newName;
c. The class creates its own with arguments for every method.
d. The class creates its own with arguments for every variable
The correct answer is: The class creates its own without any arguments.
/
Question 63 What happens if you don't put a constructor in a class definition?
Not answered
Select one:
Marked out of 1.00
a. You get an error message.
b. The class creates its own with arguments for every method.
c. The class creates its own without any arguments.
d. The class creates its own with arguments for every variable
The correct answer is: The class creates its own without any arguments.
/
Question 64 What is the output from the following code
Not answered class Test {
Marked out of 1.00 public static int x = 7;
public int y = 3;
}
public class Main {
public static void main(String[] args) {
Test a = new Test();
Test b = new Test();
a.y = 5;
b.y = 6;
a.x = 1;
b.x = 2;
System.out.print(a.y);
System.out.print(b.y);
System.out.print(a.x);
System.out.print(b.x);
}
}
Select one:
a. 3377
b. 7373
c. 5612
d. 7733
e. 5622
/
Question 65 Assume that all classes are the same package.
Not answered public class Staff {
Marked out of 1.00 int id=100;
private void m(){ System.out.println(id); }
}
public class Manager extends Staff {
int bonus=10;
void m() { System.out.println(id +"-"+ bonus); }
[1] public static void main(String[] args){
[2] Staff A=new Manager();
[3] A.m(); }
}
Choose a right statement about the code.
Select one:
a. can not access the property id from class Manager
c. 100-10
d. syntax error at row [2]
The correct answer is: can not access the method at row [3]
/
Question 66 public class A {
Not answered void m() { System.out.println( toString()) ;}
Marked out of 1.00 }
public class B {
A x=new B();
((B)x).m();
Select one:
a. you must use the try ...catch when convert datatype.
b. because "m" is the overrided method, so you do not convert any more.
c. class B can not be converted to class A.
d. can not access class B from the main method
/
Question 67 public class A {
Not answered void m() { System.out.println( toString()) ;}
Marked out of 1.00 }
public class B {
A x=new B();
((B)x).m();
Select one:
a. can not access class B from the main method
b. because "m" is the overrided method, so you do not convert any more.
c. you must use the try ...catch when convert datatype.
b. HEAP segment
c. STACK segment
/
Question 69 Declare a method by using _______ will prevent it from overriding
Not answered
Select one:
Marked out of 1.00
a. const
b. static
c. final
d. public
Question 70 what method is implemented in super class and can not be overridden in derived classes?
Not answered
Select one:
Marked out of 1.00
a. private method
b. default method
c. protected method
d. final method
b. private
c. public
d. protected
/
Question 72 Which modifiers on instance variables will announce to the compiler that these variables are
Not answered not stored as part of its object's persistent state?
b. volatile
c. synchronized
d. native
e. transient
Select one:
a. Misa, Milu
b. Milu, Milu
c. Misa, Misa
d. Milu, Misa
/
Question 74 If you want to write some functions in a class with same name but their argument lists are
Not answered different. So, what Java feature will you use?
b. Function overloading
c. Function overriding
The correct answer is: It provides access to any class in the same package.
The correct answer is: It provides access to any class in the same package.
/
Question 77 Suppose that A, B, C are classes in which B is a subclass of A. Study the following
Not answered declarations:
A objA;
Marked out of 1.00
B objB;
C objC;
Select a valid statement.
Select one:
a. objB=objC;
b. objB=objA;
c. objA=objC;
d. objC=objB;
e. objA=objB;
f. objC=objA;
c. polymorphism
d. encapsulation
/
Question 79 Real-world objects share two characteristics. They all have state and behavior. Software
Not answered objects are conceptually similar to real-world objects. they too consist of state and related
behavior. A software object stores its state in _____ and exposes its behavior through
Marked out of 1.00
______.
Select one:
a. packages, interfaces
b. fields, methods
c. methods, fields
d. classes, objects
Question 81 Which statement is used to invoke the constructor of the super class from the sub class?
Not answered
Select one:
Marked out of 1.00
a. this()
b. super()
c. extends()
d. parent()
/
Question 82 Given the following class definition
Not answered public class Cat {
Marked out of 1.00 //declare fields here…
public Cat() {
}
//more code here…
}
Which of the following is correct to create an object?
Select one:
a. Cat c = new Cat;
b. Cat c = Cat();
c. Cat c = Cat().new;
d. Cat c = new Cat();
Question 83 A subclass inherits all of the __ and ____ members of its parent.
Not answered
Select one:
Marked out of 1.00
a. public, protected
b. protected, private
c. default, public
d. default, protected
/
Question 84 Consider 2 statements below:
Not answered (1) You can write a constructor of a sub class that invokes the constructor of the super class.
Marked out of 1.00 (2) You can write a new instance method in the sub class that has the same signature as the
one in the super class.
The statement (1) is ____, and (2) is ____
Select one:
a. true, true
b. false, true
c. true, false
d. false, false
Select one:
a. 1-false, 2-true
b. 1-true, 2-false
c. 1-false, 2-false
d. 1- true, 2 -true
/
Question 86 What is the purpose of a constructor?
Not answered
Select one:
Marked out of 1.00
a. To pass values to methods for a class
b. To extend a class
c. To make objects initially have certain values when they are instantiated
d. To instantiate an object
The correct answer is: To make objects initially have certain values when they are
instantiated
Question 87 Introduce a new class by extending an existing class, this is an example of ___ .
Not answered
Select one:
Marked out of 1.00
a. Inheritance
b. Encapsulation
c. Interface
d. Polymorphism
Select one:
a. This code is invalid because the method aMethod does not access parameter.
b. This code is valid.
c. This code is invalid because the method aMethod must be prototype only.
The correct answer is: This code is invalid because the method aMethod must be prototype
only.
/
Question 89 Study the following code:
Not answered
public interface I1 {
Marked out of 1.00
void aMethod(int aValue){
System.out.println("Hi Mom");
}
}
Select one:
a. This code is valid.
b. This code is invalid because the method aMethod must be prototype only.
c. This code is invalid because the method aMethod does not access parameter.
The correct answer is: This code is invalid because the method aMethod must be prototype
only.
Select one:
a. invalid, invalid
b. valid, valid
c. valid, invalid
d. invalid, valid
/
Question 91 Study declarations:
Not answered (a)
Marked out of 1.00 public interface I1 {
}
(b)
public interface I2 {
void m();
}
The code (a) is ____, and (b) is ____
Select one:
a. invalid, valid
b. invalid, invalid
c. valid, valid
d. valid, invalid
Select one:
a. valid, invalid
b. invalid, invalid
c. valid, valid
d. invalid, valid
/
Question 93 What is a setter?
Not answered
Select one:
Marked out of 1.00
a. It is used to change a method.
The correct answer is: It is a method which is used to set or change a member variable.
The correct answer is: It cannot be accessed in other class except the class which they are
declared
/
Question 95 How do you create an instance of Box's Filler class?
Not answered class Box{
Marked out of 1.00 static class Filler{
int min, pref, max;
public Filler(int min, int pref, int max){
this.min = min;
this.pref = pref;
this.max = max;
}
}
}
Select one:
a. Box.Filler filler = new Box.Filler(1,2,3);
/
Question 96 How do you create an instance of Paragraph's Identation class?
Not answered class Paragraph{
Marked out of 1.00 class Indentation{
int left, right;
public Indentation(int left, int right){
this.left = left;
this.right = right;
}
}
}
Select one:
a. new Paragraph().Indentation(4,5);
d. Paragraph.new Indentation(4,5);
/
Question 97 public class AA {
Not answered static {
Marked out of 1.00 System.out.println("This is a AA");
}
public void m() { System.out.println("This is a BB"); }
public static void main(String[] args) {
AA x=new AA();
x.m();
}
Choose a right statement for the code.
Select one:
a. This code will display:
This is a AA
This is a BB
Question 98 Which of the following statement is not a reason for using nested classes?
Not answered
Select one:
Marked out of 1.00
a. It increases encapsulation.
c. It is a way of logically grouping classes that are only used in one place.
The correct answer is: Nested classes can lead to more readable and maintainable code.
/
Question 99 What is class-level variable?
Not answered
Select one:
Marked out of 1.00
a. A non-static variable is defined within a class but outside any method
c. A static variable that is defined within a class but outside any method
The correct answer is: A static variable that is defined within a class but outside any method
Question 100 We can apply java static keyword with variables, methods, ____ and nested class.
Not answered
Select one:
Marked out of 1.00
a. blocks
b. packages
c. constructors
d. outter classes
Question 101 We can apply java static keyword with variables, methods, ____ and nested class.
Complete
Select one:
Mark 0.00 out of
1.00 a. constructors
b. outter classes
c. packages
d. blocks
/
Question 102 We can apply java static keyword with variables, methods, ____ and nested class.
Complete
Select one:
Mark 0.00 out of
1.00 a. constructors
b. blocks
c. packages
d. outter classes
Select one:
a. true, true
b. false, true
c. true, false
d. false, false
Select one:
a. false, true
b. true, true
c. false, false
d. true, false
/
Question 105 What kind of class do you use to logically group classes that are only used in one place?
Complete
Select one:
Mark 1.00 out of
1.00 a. local class
b. anonymous class
c. nested class
Question 106 What kind of class do you use to logically group classes that are only used in one place?
Complete
Select one:
Mark 1.00 out of
1.00 a. local class
b. anonymous class
c. nested class
Question 107 Regarding to the abstract class, which one of the following is NOT true ?
Complete
Select one:
Mark 0.00 out of
1.00 a. A class containing abstract methods is called an abstract class
The correct answer is: An abstract class cannot have non-abstract methods
/
Question 108 Regarding to the abstract class, which one of the following is NOT true ?
Complete
Select one:
Mark 0.00 out of
1.00 a. Abstract methods are the ones without the body
The correct answer is: An abstract class cannot have non-abstract methods
The correct answer is: Can access non static and static variables both
Question 110 The ultimate ancestor of all Java classes is the ............ class.
Complete
Select one:
Mark 0.00 out of
1.00 a. Class
b. SuperClass
c. Starter
d. Ancestor
e. Object
/
Question 111 The Object's toString() method returns a string representation of the object which is very
Complete useful for debugging. This string includes the @ symbol, the class name of the object and
______.
Mark 0.00 out of
1.00
Select one:
a. a decimal number
c. a binary number
d. a hexadecimal number
b. immutable, fixed
c. modifiable, immutable
Question 113 What name is given to any class which is derived from another class?
Complete
Select one:
Mark 1.00 out of
1.00 a. Superclass
b. Underclass
c. Subclass
d. Overclass
/
Question 114 What is the output from the following code?
Complete class Product{
Mark 0.00 out of public void output(){
1.00 outputPrice();
outputDetail();
}
void outputPrice(){
System.out.print("Nothing.");
}
static void outputDetail(){
System.out.println("Nothing.");
}
}
class Car extends Product
{
public void outputPrice(){
System.out.print("Car’s price.");
}
public static void outputDetail(){
System.out.println("Car’s detail.");
}
}
public class Main {
public static void main(String[] args) {
Product car = new Car();
car.output();
}
}
Select one:
a. Nothing.Car’s detail.
b. Car’s price.Nothing.
c. Car’s price.Car’s detail.
d. Nothing.Nothing.
e. Nothing.Car’s price.
/
Question 115 What is it called when an instance of a class is also an instance of its super class?
Complete
Select one:
Mark 1.00 out of
1.00 a. Polymorphism
b. Instantiation
c. Encapsulation
d. Inheritance
Question 116 What is it called when an instance of a class is also an instance of its super class?
Complete
Select one:
Mark 1.00 out of
1.00 a. Encapsulation
b. Inheritance
c. Polymorphism
d. Instantiation
The correct answer is: subclass is a class that extends another class
/
Question 118 What is super keyword in Java used for?
Complete
Select one:
Mark 1.00 out of
1.00 a. refer to a object of parent class
/
Question 121 If class B is sub class from class A then which is the correct syntax?
Complete
Select one:
Mark 1.00 out of
1.00 a. class B : A
b. class B implements A
c. class B extends class A
d. class B extends A
/
Question 124 Which inheritance in Java programming is not supported?
Complete
Select one:
Mark 1.00 out of
1.00 a. Multiple inheritance using interfaces
b. Single inheritance
c. Multiple inheritance using classes
d. Multilevel inheritance
c. abstract class
d. nested class
Question 126 All of the numeric wrapper classes are sub classes of the abstract class________?
Complete
Select one:
Mark 1.00 out of
1.00 a. Integer, Float and Double
b. Integer
d. Number
/
Question 127 Which the following cases are not auto boxing?
Complete
Select one or more:
Mark 0.00 out of
1.00 a. Integer j; j = 20;
b. Integer i = 10;
Select one:
a. true
b. a
c. T
d. false
/
Question 129 Consider the code:
Complete public class Main{
Mark 1.00 out of public static void main(String[] args) {
1.00 int result=97;
char result2;
String s1="HELLO";
String s2="hello";
if (s1!=s2)
result2=(char) result;
else
result2= 'T';
System.out.println( result2);
}
}
What is the output of above code ?
Select one:
a. false
b. T
c. a
d. true
Question 130 What method is used to tell whether or not matches the given regular expression?.
Complete
Select one:
Mark 1.00 out of
1.00 a. equals()
b. matches()
c. compareTo()
d. test()
/
Question 131 If we use Math.random() method to random a number, which of the following numbers will
Complete never be appeared?
b. 0.1
c. 1.0
d. 0.4
Question 132 What does the clone() method of the java.lang.Object class support?
Complete
Select one:
Mark 0.00 out of
1.00 a. Deep comparison
b. Deep copy
c. Shallow comparison
d. Shallow copy
Question 133 Suppose that we want to convert a string of digits to an integer, which of the following
Complete classes will be used?
c. NumString
d. Digit
/
Question 134 Which of the following options is not a method of the Scanner class?
Complete
Select one:
Mark 1.00 out of
1.00 a. next()
b. nextInt()
c. nextValue()
d. nextDouble()
Question 135 Which of following primitive data is wrapped by Integer data type?
Complete
Select one:
Mark 1.00 out of
1.00 a. double
b. float
c. char
d. int
/
Question 136 Suppose that all needed packages are imported
Complete Consider below code:
Select one:
a. humpty dumpty
b. HUMPTYDUMPTY
c. hUMPTYdUMPTY
d. Humpty Dumpty
/
Question 137 Suppose that all needed packages are imported
Complete Consider below code:
Select one:
a. humpty dumpty
b. Humpty Dumpty
c. hUMPTYdUMPTY
d. HUMPTYDUMPTY
/
Question 138 Which of the following CAN NOT be stored in Character data type?
Complete
Select one:
Mark 1.00 out of
1.00 a. Special Character, e.g.$
c. Letter, e.g. A
Question 139 Which of the following CAN NOT be stored in Character data type?
Complete
Select one:
Mark 1.00 out of
1.00 a. String, e.g. Hello
b. Letter, e.g. A
Question 140 The compiler converts primitive data type into object is called ____.
Complete
Select one:
Mark 1.00 out of
1.00 a. convert
b. implicit
c. boxing
d. cast
/
Question 141 A file needs to be opened but it's name is not found in the target location then__
Complete
Select one:
Mark 1.00 out of
1.00 a. an exception will be thrown
Select one:
a. Compile-time error
b. Nothing to output
/
Question 143 Choose a right statement about checked exceptions.
Complete 1. Checked exceptions is checked at compile time.
Mark 1.00 out of 2. Checked exceptions can not be handled by the program.
1.00
Select one:
a. true, true
b. true, false
c. false, true
d. false, false
b. java.lang
c. java.io
d. java.awt
/
Question 146
Complete
Select one:
a. The sub-class is not more opened than it’s father
d. The ClassB can not create the method M3 that is the same name in ClassA
The correct answer is: The sub-class is not more opened than it’s father
Question 147
Complete
Select one:
a. The sub-class is not more opened than it’s father
b. The ClassB can not create the method M3 that is the same name in ClassA
The correct answer is: The sub-class is not more opened than it’s father
/
Question 148 What is an immutable object?
Complete
Select one:
Mark 1.00 out of
1.00 a. The one has setter methods
The correct answer is: The one with no methods to modify its fields
Question 149
__(1)__ is used to postpone the handling of a checked exception and __(2)__ is used to
Complete
create an exception explicitly.
Mark 1.00 out of Choose a coincide keyword for (1) and (2)
1.00
Select one:
a. try ... catch , throw
d. throws, throw
/
Question 150
Suppose that all needed packages are imported
Complete Consider below code:
Mark 0.00 out of public class className {
1.00
public void deposit(double amount) throws Exception {
if(amount<0) throw new Exception(“error”);
}
public static void main(String[] args){
className obj=new className();
(*) obj.deposit(100);
}
}
Choose a the way to overcome a check exception at (*).
Select one:
a. using try...catch
c. nothing to do at there
/
Question 151
Suppose that all needed packages are imported
Complete Consider below code:
Mark 0.00 out of public class className {
1.00
public void deposit(double amount) throws Exception {
if(amount<0) throw new Exception(“error”);
}
public static void main(String[] args){
className obj=new className();
(*) obj.deposit(100);
}
}
Choose a the way to overcome a check exception at (*).
Select one:
a. using try...catch
c. nothing to do at there
/
Question 152
Suppose that all needed packages are imported
Complete Consider below code:
Mark 0.00 out of public class className {
1.00
public void deposit(double amount) throws Exception {
if(amount<0) throw new Exception(“error”);
}
public static void main(String[] args){
className obj=new className();
(*) obj.deposit(100);
}
}
Choose a the way to overcome a check exception at (*).
Select one:
a. nothing to do at there
c. using try...catch
/
Question 153
public class ExcepTest {
Complete
public static void main(String args[]) {
Mark 1.00 out of
int a[] = new int[2];
1.00
try {
System.out.println("Access element three :" + a[3]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Exception thrown :" + e);
}finally {
a[0] = 6;
System.out.println("First element value: " + a[0]);
System.out.println("The finally statement is executed");
}
}
}
This method returns _______.
Select one:
a. Exception thrown :java.lang.ArrayIndexOutOfBoundsException: 3
First element value: 6
The finally statement is executed
/
Question 154
Suppose that all needed packages are imported
Complete Consider below code:
Mark 0.00 out of class CoffeeCup {
1.00 int temperature = 75;
//...
}
public class Person {
static final int tooCold = 65;
static final int tooHot = 85;
public void drinkCoffee(CoffeeCup cup) throws Exception{
int temperature = cup.temperature;
if (temperature <= tooCold)
throw new Exception("Too cold");
else
if (temperature >= tooHot)
throw new Exception("Too hot");
else
System.out.println(temperature + "is great");
}
//..
public static void main(String[] args){
Person a=new Person();
a.drinkCoffee(new CoffeeCup()); // (*)
}
}
Select one:
a. 75 is great
c. nothing is displayed
The correct answer is: A compilation error message is displayed at the row (*)
/
Question 155
Suppose that all needed packages are imported
Complete Consider below code:
Mark 0.00 out of class CoffeeCup {
1.00 int temperature = 75;
//...
}
public class Person {
static final int tooCold = 65;
static final int tooHot = 85;
public void drinkCoffee(CoffeeCup cup) throws Exception{
int temperature = cup.temperature;
if (temperature <= tooCold)
throw new Exception("Too cold");
else
if (temperature >= tooHot)
throw new Exception("Too hot");
else
System.out.println(temperature + "is great");
}
//..
public static void main(String[] args){
Person a=new Person();
a.drinkCoffee(new CoffeeCup()); // (*)
}
}
Select one:
a. A compilation error message is displayed at the row (*)
c. 75 is great
d. nothing is displayed
The correct answer is: A compilation error message is displayed at the row (*)
/
Question 156 Choose a right statement.
Complete 1. It's necessary that each try block must be followed by a finally block.
Mark 0.00 out of 2. Using try...catch to throw an exception to other method.
1.00
Select one:
a. true, false
b. false, false
c. true, true
d. false, true
Question 157 How can you iterate over the elements of a Set?
Complete
Select one:
Mark 0.00 out of
1.00 a. Using for-each statement: for (Object o : list) { System.out.println(o);}
b. Using iterators:while (iter.hasNext()) { System.out.println(iter.next());}
Select one:
a. false, false
b. false, true
c. true,true
d. true, false
/
Question 159 A _____ can contain distinct elements only.
Complete
Select one:
Mark 1.00 out of
1.00 a. Vector
b. SortedSet
c. List
d. Queue
b. java.util
c. java.lang
d. java.framework
e. java.colectionframework
The correct answer is: Values stored in TreeSet are not allowed duplication
/
Question 162 Which of the following collection cannot be used with Iterator class to traverse through
Complete elements?
b. HashMap
c. ArrayList
d. Array
Question 163 In Java Collection framework, which of the following pre-defined classes allow an element
Complete can be accessed through its index?
b. java.util.TreeMap
c. java.util.HashSet
d. java.util.ArrayList
b. List
c. File
d. Set
/
Question 165 How to loop through a collection?
Complete
Select one:
Mark 0.00 out of
1.00 a. using foreach loop
/
Question 167 Suppose that all needed packages are imported
Complete Consider the below code:
Select one:
a. Generic type
b. Object
c. <T>
d. Number
c. Object
d. extends
/
Question 169 Suppose that all needed packages are imported
Complete Consider below code:
Select one:
a. Because Java finds duplicates in a TreeSet.
Question 170 what method is used to return the number of elements in the specified collection equal to the
Complete specified object?
b. countElements
c. disjoint
d. binarySearch
/
Question 171 what method is used to return the number of elements in the specified collection equal to the
Complete specified object?
b. binarySearch
c. frequency
d. countElements
Question 172 what method is used to return the number of elements in the specified collection equal to the
Complete specified object?
b. binarySearch
c. frequency
d. disjoint
b. disjoint
c. binarySearch
d. descending
/
Question 174 What method is used to sort the collection?
Complete
Select one:
Mark 1.00 out of
1.00 a. binarySearch
b. descending
c. disjoint
d. sort
Question 175 Assume that all lib files are imported. What is the output from the following code?
Complete public class Sort {
Mark 1.00 out of public static void main(String[] args) {
1.00
String s = "java sort i walk the line";
System.out.println(list);
}
Select one:
a. [Ljava.lang.String;@15db9742]
b. Nothing to output
The correct answer is: [i, java, line, sort, the, walk]
/
Question 176 Assume that all lib files are imported. What is the output from the following code?
Complete public class Sort {
Mark 1.00 out of public static void main(String[] args) {
1.00
List<String> list = new ArrayList<String>();
list.add("1");
list.add("123");
list.add("12");
@Override
});
System.out.println(list);
Select one:
a. [123, 12, 1]
b. Run-time error
/
Question 177 Assume that all lib files are imported. What is the output from the following code?
Complete public class Sort {
Mark 1.00 out of public static void main(String[] args) {
1.00
List<String> list = new ArrayList<String>();
list.add("1");
list.add("123");
list.add("12");
@Override
});
System.out.println(list);
Select one:
a. Run-time error
c. [123, 12, 1]
d. [1, 123, 12]
/
Question 178 Assume that all lib files are imported.
Complete public class test{
Mark 1.00 out of public static void main(String[] args) {
1.00 List<String> list=Array.asList(args);
Collections.sort(list);
System.out.println(list);
}
}
What is the output of above code when the program runs with arguments: "i" "go" "to"
"school"?
Select one:
a. [i, go, school, to]
Question 179 What class consists exclusively of static methods that operate on or return collections?
Complete
Select one:
Mark 1.00 out of
1.00 a. Arrays
b. Collection
c. Collections
d. Map
/
Question 180 What class are methods such as reverse, shuffle offered in?
Complete
Select one:
Mark 1.00 out of
1.00 a. Collections
b. Object
c. Apache Commons Collections
d. Collection
Question 181 What class are methods such as reverse, shuffle offered in?
Complete
Select one:
Mark 1.00 out of
1.00 a. Object
b. Apache Commons Collections
c. Collections
d. Collection
Question 182 What kind of parameter type is used for a generic class to return and accept any types of
Complete object?
b. T
c. V
d. K
/
Question 183 What kind of parameter type is used for a generic class to return and accept any types of
Complete object?
b. K
c. T
d. N
Question 184 What kind of parameter type is used for a generic class to return and accept any types of
Not answered object?
b. V
c. K
d. T
/
Question 185 What is the output from the following code?
Complete public class Generics {
Mark 1.00 out of public static void main(String[] args) {
1.00
int n=10, m=20;
System.out.println(add(n, m));
}
public static <T> T add(T num1, T num2){
Select one:
a. 0
b. Run-time error
c. Compile-time error
d. 30
/
Question 186 What is the output from the following code?
Complete public class Generics {
Mark 1.00 out of public static void main(String[] args) {
1.00
int n=10, m=20;
System.out.println(add(n, m));
}
Select one:
a. Run-time error
b. 30
c. Compile-time error
d. 0
Question 187 Assume that all lib files are imported. What is the output from the following code?
Complete public class Generics {
Mark 1.00 out of public static void main(String[] args) {
1.00
ArrayList list = new ArrayList<String>();
list.add("Hello Generics");
System.out.println(list);
Select one:
a. Compile-time error
b. Nothing to output
c. Run-time error
d. [Hello Generics]
/
Question 188 Assume that all lib files are imported. What is the output from the following code?
Complete public class Generics {
Mark 1.00 out of public static void main(String[] args) {
1.00
ArrayList list = new ArrayList<String>();
list.add("Hello Generics");
System.out.println(list);
Select one:
a. Compile-time error
b. Run-time error
c. [Hello Generics]
d. Nothing to output
b. FileWriter
c. FileReader
d. ObjectInputStream
/
Question 191 Which of these class is used to read characters in a file?
Complete
Select one:
Mark 0.00 out of
1.00 a. FileWriter
b. FileInputStream
c. ObjectInputStream
d. FileReader
b. java.io.ObjectInputStream
c. java.io.Deserializable
d. java.io.ObjectOutputStream
c. ObjectOutputStream
d. De-serialization
/
Question 194 The process of writing an object is called ____.
Complete
Select one:
Mark 1.00 out of
1.00 a. ObjectOutputStream
b. ObjectInputStream
c. De-serialization
d. Serialization
b. DataInputStream, DataOutputStream
c. ObjectInputStream, ObjectOutputStream
d. Reader, Writer
Question 196 Which package needs to be imported so that you can accept user input?
Complete
Select one:
Mark 1.00 out of
1.00 a. java.io
b. java.awt.event
c. java.util
d. java.awt
/
Question 197 In _____ binary streams, a read/write data unit is _______.
Complete
Select one:
Mark 0.00 out of
1.00 a. high-level, byte
b. low-level, byte
b. low-level, byte
d. high-level, byte
/
Question 200 When reading objects from an object stream, we usually use _____.
Complete
Select one:
Mark 0.00 out of
1.00 a. an implicit class conversion
c. no type changes
Dream of Innovation.
Quick Links
About Us
Terms of use
FAQ
Support
Follow Us
Contact
Innovation Building, QTSC, D.12, HCMc
Phone: (848) 543 711 97
E-mail: [email protected]