Search Header Logo

Java.io - 1

Authored by Jose Diaz

Computers

1st Grade

Used 4+ times

Java.io - 1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Identify correct statements about java.io.Console class?. Please select 1 option.

You can read character data from a console but not write to it.

You can read both binary and character data from Console object but you cannot write to it.

You can read both binary and character data from Console object but you can only write character data to it.

You can read as well as write only character data from/to it.

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Given:

Path p1 = Paths.get("c:\\a\\b\\c.java");

What will p1.getName(2).toString() return? . Please select 1 option.

a

b

c

c.java

3.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

What will the following code fragment print?

Path p1 = Paths.get("photos\\..\\beaches\\.\\calangute\\a.txt");

Path p2 = p1.normalize();

Path p3 = p1.relativize(p2);

Path p4 = p2.relativize(p1);

System.out.println( p1.getNameCount()+" "+p2.getNameCount()+" "+ p3.getNameCount()+" "+p4.getNameCount()); Please select 1 option.

6 4 10 10

7 4 11 10

7 3 8 9

6 3 1 1

4.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

What will the following code print?

Path p1 = Paths.get("c:\\temp\\test.txt");

Path p2 = Paths.get("report.pdf");

System.out.println(p1.resolve(p2)); Please select 1 option.

..\report.pdf

c:\temp\test.txt\report.pdf

c:\temp\report.pdf

It will throw an exception.

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Assuming that the file module-info.java exists in c:\\temp\\src\\foo.bar but not in c:\\temp\\out\\foo.bar and the folder foo.bar exists in c:\\temp\\out, what will happen when the following code is run?

Path p1 = Paths.get("c:\\temp\\src\\foo.bar\\module-info.java");

Path p2 = Paths.get("c:\\temp\\out\\foo.bar");

Files.move(p1, p2); Please select 1 option.

module-info.java will be copied over to out\foo.bar folder.

module-info.java will be moved to out\foo.bar folder.

An exception will be thrown.

module-info.java will be moved to out with the name foo.bar.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?