Java
Is an empt ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
Is an empty file allowed to compile?
Yes
No
Explanation
Before the compiler starts processing a file, it does not know its content. An empty file does not contain any error, like a file with only comments. But such a file does not produce a class file.
compilation
source-file
1
(3)
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
What will be printed out as a result of the following code execution / compilation? public class Test { static void m(int ... a) { System.out.println("1"); } static void m(Integer ... a) { System.out.println("2"); } public static void main(String[] args) { m(1, 2); } }
What will be the result of the following code compilation and execution? public class Test { final String s; public Test() { s = "default"; } public Test(String s) { } public static void main(String[] args) { System.out.println(new Test().s); } }
What will be the result of the compilation and execution of the following code: interface I { public final static int EASY = 5; } public class Main implements I { public static void main(String[] args) { int a = 5; test(++a); } static void test(int a) { a += EASY + a++; System.out.println(a); } }
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(); } } }
What lines will the compilation error occur in: class MyException1 extends Exception { } // 1 class MyException2 extends RuntimeException { } // 2 class A { void m1() { throw new MyException1(); } // 3 void m2() { throw new MyException2(); } // 4 }
J
ava
Quiz
Login to learn Java
or
Read more about
Java Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
Java quizzes
What will be printed out as a result of the following code execution / compilation? class A { public A() { System.out.print("A"); } } class B { public B() { System.out.print("B"); } } class C { public C() { System.out.print("C"); } } public class D extends C { private A objA = new A(); private static B objB = new B(); public D() { System.out.print("D"); } public static void main(String[] args){ new D(); } }
What will be printed out as a result of the following code execution / compilation? public class Test { private String name; Test(String name) { this.name = name; } public void test(final Test test) { test = new Test("three"); } public String toString() { return name; } public static void main(String[] args) { Test t1 = new Test("one"); Test t2 = new Test("two"); t1.test(t2); System.out.println(t2); } }
What will be printed out as a result of the following code execution / compilation? public class Test { public static void main(String[] args) { ElectricInverter inverter = new ElectricInverter(); int AC = 220; System.out.println(inverter.invert(AC)); } } class ElectricInverter { public static final int AC = ~220; public static final int DC = -110; public static final int GROUND = 0; int invert(int type) { if (type == AC) { return DC; } else if (type == DC) { return AC; } return GROUND; } }
int i = Integer.MAX_VALUE + 10; What is the result of the given line execution?
What happens after the following code is compiled and run: 01: interface TheInterface { 02: void print(); 03: } 04: 05: class TheClass implements TheInterface { 06: public void print() { 07: System.out.println("TheClass"); 08: } 09: } 10: 11: public class ClassConversion { 12: public static void main(String[] args) { 13: TheClass c = new TheClass(); 14: TheInterface i = c; 15: i.print(); 16: } 17: }
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()); } }
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment