Java Skill Assessment Test

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By R2international
R
R2international
Community Contributor
Quizzes Created: 1 | Total Attempts: 7,591
| Attempts: 7,591 | Questions: 23
Please wait...
Question 1 / 23
0 %
0/100
Score 0/100
1. Synchronized is a keyword to tell a Thread to grab an Object lock before continuing execution.

Explanation

The explanation for the given correct answer is that the "synchronized" keyword in Java is used to ensure that only one thread can access a block of code or an object at a time. It grabs an object lock before executing the synchronized code, preventing other threads from accessing it simultaneously. This helps in preventing race conditions and maintaining data integrity in multi-threaded environments. Therefore, the statement "Synchronized is a keyword to tell a Thread to grab an Object lock before continuing execution" is true.

Submit
Please wait...
About This Quiz
Java Skill Assessment Test - Quiz

This test will measure the applicants knowledge and competency in the technical field of Java development and programming

2. Methods that are marked protected can be called in any subclass of that class.

Explanation

Protected methods in a class can be accessed by any subclass of that class. This means that even if the subclass is in a different package or module, it can still call the protected method. This is because protected access allows for inheritance and provides a way for subclasses to access and modify the behavior of the superclass. Therefore, the given answer, which states that protected methods can be called in any subclass of the class, is true.

Submit
3. An abstract class can have non-abstract methods.

Explanation

An abstract class can have non-abstract methods because an abstract class is a class that cannot be instantiated and is meant to be extended by other classes. It can contain both abstract and non-abstract methods. Non-abstract methods in an abstract class can have a defined implementation, allowing the abstract class to provide common functionality to its subclasses. Subclasses that extend the abstract class can inherit and use these non-abstract methods without needing to redefine them. Therefore, it is true that an abstract class can have non-abstract methods.

Submit
4. Primitive datatypes are allocated on a stack.

Explanation

Primitive datatypes are allocated on a stack because they are small and have a fixed size. The stack is a region of memory that is used for local variables and function calls. When a primitive datatype is declared, memory is allocated on the stack to store its value. This memory is automatically freed when the variable goes out of scope. This is in contrast to objects, which are allocated on the heap and require manual memory management.

Submit
5. Can you compare a boolean to an integer?

Explanation

A boolean represents a binary value, either true or false, while an integer represents a numerical value. These two types are not directly comparable as they have different representations and purposes. In most programming languages, attempting to compare a boolean to an integer would result in a type error. Therefore, the correct answer is "No".

Submit
6. Java keywords are written in lowercase as well as uppercase

Explanation

Java keywords are written in lowercase only. This is because Java is case-sensitive, meaning that uppercase and lowercase letters are treated as different characters. Therefore, using uppercase letters in keywords would result in a compilation error.

Submit
7. Following code will result in: int a1 = 5; double a2 = (float)a1;

Explanation

The given code will not result in any errors. It declares an integer variable "a1" with a value of 5 and a double variable "a2" which is assigned the value of "a1" after casting it to a float. Since the casting is allowed and there are no other issues with the code, it will compile and run without any errors.

Submit
8. Following code will result in: class A { public static void main(String [] args) {A a = new B(); }} class B extends A {}

Explanation

The given code will not result in any errors because class B is a subclass of class A, so it is valid to assign an instance of B to a variable of type A. Therefore, the code will compile successfully and run without any issues.

Submit
9. What is an instanceof

Explanation

The correct answer is "An operator and keyword". The instanceof operator is used to check if an object belongs to a certain class or implements a certain interface. It returns true if the object is an instance of the specified class or interface, and false otherwise. It is a keyword in Java that is used in conjunction with the operator to perform this check.

Submit
10. Following code will result in: int a = 3.5;

Explanation

The code will result in a compilation error because the variable "a" is declared as an integer, but it is being assigned a value of 3.5, which is a floating-point number. In Java, you cannot assign a floating-point value to an integer variable without explicitly casting it.

Submit
11. A class can be transient

Explanation

A class cannot be transient. The "transient" keyword in programming languages is used to indicate that a variable should not be serialized, meaning it will not be included when the object is converted into a stream of bytes. However, the "transient" keyword cannot be applied to a class itself. It can only be used with variables within a class. Therefore, the correct answer is False.

Submit
12. Following code will result in: class A { public static void main(String [] args) {B b = new A(); }} class B extends A {}

Explanation

The code will result in a compile error because it is trying to create an instance of class A using the constructor of class B. Since class B extends class A, it is possible to create an instance of class B using the constructor of class A, but not the other way around. Therefore, the code is not valid and will not compile.

Submit
13. What is the size of a Char?

Explanation

The size of a Char is 16 bits. This means that a Char data type can store values ranging from -32,768 to 32,767.

Submit
14. Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if (a==b)?

Explanation

When comparing two objects using the == operator, it checks if the two objects are referring to the same memory location. In this case, since both objects a and b are created using the new keyword, they are stored in different memory locations even though they have the same value. Therefore, the condition (a==b) evaluates to false.

Submit
15. What is default layout manager for panels and applets?

Explanation

The default layout manager for panels and applets is FlowLayout. FlowLayout arranges components in a left-to-right flow, wrapping them to the next line if there is not enough space horizontally. This layout manager is commonly used when you want components to be displayed in a simple, linear fashion.

Submit
16. A class cannot be declared

Explanation

A class cannot be declared as private because the access modifier "private" restricts the visibility of members to only within the same class. However, a class needs to be accessible outside of its own class in order to be used by other classes or objects. Therefore, a class can be declared as static or default, but not as private.

Submit
17. Following code will result in: int a = 9/0;

Explanation

The code will result in a Runtime Exception because it is attempting to divide 9 by 0, which is not possible and will cause an ArithmeticException to be thrown at runtime.

Submit
18. Following code will result in: class A { int b = 1; public static void main(String [] args) { System.out.println("b is " + b); }}

Explanation

The code will result in a compilation error because the variable "b" is an instance variable and cannot be accessed directly from a static method (main method). To access the instance variable, an object of class A needs to be created.

Submit
19. Which one does not extend java.lang.Number

Explanation

The correct answer is Boolean and Character because they do not extend the java.lang.Number class. The java.lang.Number class is the superclass of all the numeric wrapper classes in Java, such as Integer, Long, and Short, which means they extend the Number class. However, Boolean and Character are not numeric types and thus do not extend the Number class.

Submit
20. You execute the code below in an empty directory. What is the result? File f1 = new File("dirname"); File f2 = new File(f1, "filename");

Explanation

The code creates two File objects, f1 and f2. The constructor for f1 takes a string parameter "dirname", which represents a directory name. However, the code does not actually create a directory or a file. It simply creates the File objects with the given names. Therefore, the correct answer is that no directory is created, and no file is created.

Submit
21. Following code will result in: float a = 9/0;

Explanation

The code will not result in a compilation error or a runtime exception. Instead, it will assign the value NaN (Not a Number) to the variable 'a'. This is because dividing any number by zero in floating-point arithmetic results in NaN.

Submit
22. The default statement of a switch is always executed

Explanation

not-available-via-ai

Submit
23. Which of the following statements are true?

Explanation

The first statement is true because if the filenaming semantics of the local machine are not used when constructing an instance of File, the constructor will throw an IOException. The second statement is also true because if the corresponding file does not exist on the local file system, it will be created when constructing an instance of File. However, the third statement is false. When an instance of File is garbage collected, it does not automatically delete the corresponding file on the local file system.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

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

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 17, 2009
    Quiz Created by
    R2international
Cancel
  • All
    All (23)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Synchronized is a keyword to tell a Thread to grab an Object lock...
Methods that are marked protected can be called in any subclass of...
An abstract class can have non-abstract methods.
Primitive datatypes are allocated on a stack.
Can you compare a boolean to an integer?
Java keywords are written in lowercase as well as uppercase
Following code will result in: int a1 = 5; double a2 = (float)a1;
Following code will result in: class A { public static void...
What is an instanceof
Following code will result in: int a = 3.5;
A class can be transient
Following code will result in: class A { public static void...
What is the size of a Char?
Integer a = new Integer(2); Integer b = new Integer(2); What happens...
What is default layout manager for panels and applets?
A class cannot be declared
Following code will result in: int a = 9/0;
Following code will result in: class A { int b = 1; public static void...
Which one does not extend java.lang.Number
You execute the code below in an empty directory. What is the result?...
Following code will result in: float a = 9/0;
The default statement of a switch is always executed
Which of the following statements are true?
Alert!

Advertisement