Core Java - Interview Questions and Answers for 'Compilation' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Compilation' - 7 question(s) found - Order By Newest

 Q1. Will this code compile ?

public class BuggyBread1{
abstract public void test();
}
Core Java
Ans. No. It will give the compilation error saying "The abstract method test in type BuggyBread1 can only be defined by an abstract class".

We need to declare the class abstract for it to have any abstract method.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops   abstract class   abstract methods   java compilation error


 Q2. Will this Code compile ?

abstract public class BuggyBread1{
abstract public void test(){};
}
Core Java
Ans. No. This will give a compilation error saying "Abstract methods do not specify a body".

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   abstract classes   abstract methods   java compilation error   java coding   java code   coding   yes-no


 Q3. What is a compilation unit in Java ?
Ans. Java Source Code File

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     compilation unit in java


 Q4. What is the difference between compilation and decompilation ?Core Java
Ans. Compilation is the process of converting Java source files to class files which can be executed by the Java runtime environment whereas Decompilation is the process of converting class files back to the Java Source code.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     compilation vs decompilation  compiler vs decompiler


 Q5. Upon compiling the following class, What .class files will get created

public class OuterClass{
class InnerClass{
}
}
Core Java
Ans. OuterClass.class AND OuterClass$InnerClass.class

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     class files  compilation  compile  inner classes   nested classes


 Q6. Can we compile and execute a Java class without main method ?Core Java
Ans. No without main method can not be executed it will throw an error illegal start of type. Main method is the entry point of application.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  compilation  main method      Basic


 Q7. What will the following code print and Why

class Class1 {
static{
System.out.println("Wow");
}
public static final int xyz=1;
}

class Class2{
public static void main(String[] args) {
System.out.println(String.valueOf(Class1.xyz));
}
}
Core Java
Ans. 1

Reason being that Class1.xyz is replaced with 1 during pre compilation only and a reference to Class1 is never made.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     static final   pre compilation



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: