Evaluate Your Knowledge Of Core Java

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Bmondal
B
Bmondal
Community Contributor
Quizzes Created: 2 | Total Attempts: 1,238
Questions: 5 | Attempts: 321

SettingsSettingsSettings
Evaluate Your Knowledge Of Core Java - Quiz


Questions and Answers
  • 1. 

    Which is the correct way to declare and store a character value to a variable?

    • A.

      Char ch="A"

    • B.

      Char ch='A'

    • C.

      Char [] ch='A'

    • D.

      Char []ch="A"

    Correct Answer
    B. Char ch='A'
    Explanation
    The correct way to declare and store a character value to a variable is by using the syntax "char ch='A'". In this case, the variable "ch" is declared as a character type and assigned the value 'A'.

    Rate this question:

  • 2. 

    How execute a java program? Programe file name is "Example.java".

    • A.

      Java Example

    • B.

      Javac Example

    • C.

      Java Example.java

    • D.

      Javac Example.java

    Correct Answer
    A. Java Example
    Explanation
    To execute a Java program with the file name "Example.java", the correct command is "java Example". This command runs the compiled bytecode file generated by the "javac" command. The "javac" command is used to compile the Java source code file into bytecode. Therefore, options "javac Example" and "javac Example.java" are incorrect as they are used for compilation, not execution. The correct command to execute the program is "java Example".

    Rate this question:

  • 3. 

    While key words allow us to use class variable with our declaring the object of the class?

    • A.

      Final

    • B.

      Abstract

    • C.

      Interface

    • D.

      Static

    Correct Answer
    D. Static
    Explanation
    The correct answer is "static". The keyword "static" allows us to use class variables without declaring an object of the class. Static variables are shared among all instances of a class and can be accessed directly using the class name.

    Rate this question:

  • 4. 

    Which of following is the correct declaration of main method?

    • A.

      Static public void main(String []a)

    • B.

      Void public static main()

    • C.

      Void public static main(String a[])

    • D.

      Public static main(String a[])

    Correct Answer
    A. Static public void main(String []a)
    Explanation
    The correct declaration of the main method is "static public void main(String []a)". In Java, the main method is the entry point of a program and it must be declared as public, static, and void. The "public" keyword allows the method to be accessed from outside the class, the "static" keyword allows the method to be called without creating an instance of the class, and the "void" keyword indicates that the method does not return any value. The main method also takes a parameter of type String array, which allows command-line arguments to be passed to the program.

    Rate this question:

  • 5. 

    Predict the output. abstract class cal {"\n" abstract public void sum(); abstract public void mul(); } public class calculation extens cal { int a=10,b=20,res=0; public void sum() { res=a+b; System.out.println("Result is : " +res); } public static void main(String []a) { calculation c=new calculation(); c.sum(); } }

    • A.

      Result is : 30

    • B.

      Result is : 0

    • C.

      Compile time error

    • D.

      Runtime error

    Correct Answer
    C. Compile time error
    Explanation
    Programe will generate compile time error.
    calculation is not abstract and does not override abstract method "mul()"

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Oct 04, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 21, 2012
    Quiz Created by
    Bmondal
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.