Тесты
Язык сайта: Русский
Українська
English
Русский
Тесты по программированию
Вход
Регистрация
Тесты по программированию
Теория
сниппеты
Статьи
Главная
Android
Цены
FAQ
История Cosmo
Правила и условия сервиса
Политика конфиденциальности
Политика в отношении файлов cookie
Обратная Связь
input and output
:
Язык контента: English
Русский
What will be the result of the following program execution? import java.util.*; public class TestFormatter { public static void main(String... args){ Integer I1 = 0; Integer I2 = -1; Integer I3 = 1; Formatter f = new Formatter(); f.format("%1$b ", I1.toString()) .format("%1$b ", I2.toString()) .format("%1$b ", I3.toString()); System.out.println(f.toString()); } }
input and output
What will happen when you try to compile and run the following code? It is assumed that the outstream file is already created. import java.io.*; public class Main { public static void main(String[] args) { try { FileInputStream fis = new FileInputStream("outstream"); InputStreamReader isr = new InputStreamReader(fis); BufferedReader br = new BufferedReader(isr); try { do { String str = br.readLine(); System.out.println(str); } while (str != null); } finally { fis.close(); isr.close(); br.close(); } } catch(IOException e){ e.printStackTrace(); } } }
input and output
Given the following code public class OverrideThrowsTest { public static void main(String[] args) // 1 { A a = new A(); a.method(); A ab = new B(); ab.method(); B b = new B(); b.method(); } } class A { public void method() throws IOException {} } class B extends A { public void method() throws FileNotFoundException {} } Select all the answers, for which, if placed into line 1, code will compile.
input and output
What will be displayed as a result of the following program execution? public class Main { public static void main(String[] args) { Formatter formatter = new Formatter(Locale.ROOT); formatter.format("%.2E\n", 100.0/3.0); //1 formatter.format("%.2f", 100.0/3.0); //2 System.out.println(formatter); } }
input and output
What will be displayed and what will be printed to a test.out text file as a result of the following code execution? package question; import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; public class TestOutput { public static void main(String[] args) throws IOException { PrintStream out = new PrintStream( new BufferedOutputStream(new FileOutputStream("test.out"))); PrintStream console = System.out; System.setOut(console); System.out.println("FIRST OUTPUT"); System.setOut(out); System.out.println("SECOND OUTPUT"); out.close(); System.out.println("THIRD OUTPUT"); } }
input and output
What should be placed insted of ... in order to read the content of the C:\file.txt file and print it out on the screen? Select all that will work public class Main { public static void main(String[] args) { File file = new File("C:\\file.txt"); try { ... int i; while((i = input.read()) != -1){ System.out.print((char)i); } } catch (Exception ex) { System.out.println("Exception"); } } }
input and output
What is the result of the program: import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class NewClass { public static void main(String[] args) throws Exception { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ObjectOutputStream oOut = new ObjectOutputStream(bOut); Whole object = new Whole(); oOut.writeObject(object); } } class Whole implements Serializable { public void writeObject(ObjectOutputStream out) { System.out.println("Whole.writeObject()"); } }
input and output
What is the result of compiling and running the following code? public class Quest { public static void main(String[] args) { byte b[] = new byte[80]; for (int i = 0 ; i < b.length ; i++) b[i] = (byte)System.in.read(); System.out.print(“Ok”); } }
input and output
What will be the result of compilation and running the following code: import java.util.Formatter; public class Formating { static Formatter formatter = new Formatter(); public static void main(String[] args) { System.out.print( formatter.format("%b %b %b", new Boolean(null), new Boolean("bool"), 8 ) ); } }
input and output
Choose the correct result of compiling and running following code: import java.util.Formatter; public class Format2 { public static void main(String[] args) { String s = "hello123"; Formatter f = new Formatter(); f.format("%S", s); System.out.println(f); } }
input and output
← Предыдущая
1
2
Следующая →
Зарегистрируйся сейчас
или
Подпишись на будущие тесты