The createNewFile() method of the File class is used to create a new empty file if a file with the given name does not already exist. It returns true if a file with the given name does not exist and is successfully created; otherwise, it returns false.
Archive for the ‘ Java Questions ’ Category
What is the createNewFile() method of the File class?
Author: Daisy WilliamsDec 12
What will be the output of the following code?
Author: Daisy WilliamsDec 5
class TestInstanceof {
public static void main(String[] args) {
Integer i=5;
Boolean b;
b=(i instanceof Integer);
System.out.print(b);
b=(i instanceof Number);
System.out.println(b);
}
}
Which of the following operations are allowed for collection framework?
Author: Daisy WilliamsDec 4
A: Adding objects to a collection
B: Iterating through a collection
C: Finding out if an object is in a collection
D: Retrieving an object from a collection
All answer options are correct because:
The Collections Framework in Java is a hierarchy of interfaces and classes that provides a technology for managing a group of objects. It is used to provide a central and unified theme for managing a group of objects. The Java Collections Framework is designed to meet the following goals:
- To offer high performance in terms of efficiency.
What will be the output of the following program code?
Author: Daisy WilliamsDec 3
import java.util.*;
public class TestArray{
public static void main(String[] args){
TestArray test = new TestArray();
test.go();
}
public void go(){
int[] arr = new int[] {1,2,3,4,5,6};
//add code here
}
}