LinkedIn Java Skill Assessment Answers 2022 - ( Latest Updated )
LinkedIn Java Skill Assessment Answers 2022. Hello dear learner, We have shared top score answers of java skill assessment answers. If you want build your career on linkedin. Then this skill test are help you as well. We have daily shared all type of skill test question and answers.
If you like this article then, please see our other post and share with your friend and social media. like, facebook, instagram, twitter.
Table of content
- How do I pass skills assessment test on LinkedIn?
- Where are my LinkedIn assessment answers?
- Can you retake LinkedIn skill assessments?
- Are LinkedIn skill assessments worth it?
LinkedIn Java Skill Assessment Answers 2022
Question 1. Java Assessment How do you convert this method into a lambda expression?
public int square(int x) { return x * x;
Function squareLambda = x - x * x;
Function Integer, Integer> squareLambda = () -> (return x * x);
Function squareLambda = (int x) -> { x * x };
Function squareLambda = x -> return x * x;
Question 2. Java Assessment Which choice is the best data type for working with money in Java?
double
float
String
BigDecimal
Question 3. Which choice is a valid implementation of this interface?
interface My Interface { int foo(int x);
public class MyClass implements MyInterface { public double foo(int x) { return x * 100;
public class MyClass implements MyInterface { 1/ ... public int foo() { return 100;
public class MyClass implements MyInterface { public void foo(int x) { System.out.println(x);
public class MyClass implements MyInterface { // ... public int foo(int x) { return x * 100;
Question 4 . Given the string "strawberries" saved in a variable called fruit, what would "fruit.substring(2, 5)" return?
rawb
raw
awb
traw
Question 5. Fill in the blank to create a piece of code that will tell whether into is divisible by 5:
boolean isDivisibleBy5 = -__
Math.inDivisible(inte, 5)
into % 5 == 0
into / 5 ? true : false
into % 5 != 5
Also read our LinkedIn Microsoft Excel Assessment Answers
Question 6. Java Assessment Which is not a valid lambda expression?
String a -> false;
a -> false;
(String a) -> false;
(a) -> false;
Question 7. When should you use a static method?
when your method uses an object's instance variable
when your method is related to the object's characteristics
when you want your method to be available independently of class instances
when your method is dependent on the specific instance that calls it
QQuestion 8. How can you achieve runtime polymorphism in Java?
method overloading
method overrunning
method overriding
method calling
Question 9. What will this program print out to the console when executed?
import java.util.LinkedList; public class Main { public static void main(String[] args) { LinkedList list = new LinkedList<>(); list.add(5); list.add(1); list.add(10); System.out.println(list);
[10, 5, 1]
[5, 1, 10]
[1, 5, 10]
[10, 1, 5]
QQuestion 10. Given the following definitions, which of these expression will NOT evaluate to true?
boolean b1 = true, b2 = false; int i1 = 1, i2 = 2;
- (i1 | i2) == 3
- i2 && b1
- b1 || !b2
- (i1 ^ i2) < 4
Question 11. Refactor this event handler to a lambda expression. grouchyButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { System.out.println("Press me one more time..."); });
grouchy Button.addActionListener(ActionListener listener -> System.out.println("Press me one more time..."));
grouchyButton.addActionListener(new ActionListener(ActionEvent e) { -> System.out.println("Press me one more time..."); });
grouchyButton.addActionListener(( -> System.out.println("Press me one more time..."));
grouchyButton.addActionListener((event) -> System.out.println("Press me one more time..."));
QQuestion 12. What can you use to create new instances in Java?
constructor
another instance
field
private method
Question 13. How would you declare and initialize an array of 10 ints?
Array numbers = new Array(Integer>(10);
int[] numbers = new int[10];
int numbers [] = int(10];
Array[int] numbers = new Array[int](10);
Question 14. What is the output of this code?
1: class Main {
2: public static void main (String[] args) {
3: int array[] = {1, 2, 3, 4};
4: for (int i = 0; i < array.size(); i++) {
5: System.out.print(array[i]);
}
}
}
It will not compile because of line 4
It will not compile because of line 5.
321
4321
Also read our: LinkedIn Marketing Solutions Fundamentals Certification Answers
Question 15. Java Assessment How does the keyword volatile affect how a variable is handled?
It will be preferentially garbage collected.
It will be read from the computer's main memory and not from the CPU cache.
It will be stored on the hard drive.
It will be read by only one thread at a time.
QQuestion 16. What does the following code print?
String str = ""abcde"";
str.trim();
str.toUpperCase();
str.substring(3, 4);
System.out.println(str);
- CD
- CDE
- D
- "abcde"
QQuestion 17. How do you force an object to be garbage collected?
There is no way to force an object to be garbage collected.
Set the object to null and call Runtime.gc(). o
Set the object to null and call Runtime.getRuntime().runFinalization(). o
Set the object to null and call System.gc().
Question 18. Which characteristic does not apply to instances of java.util.HashSet?
contains sorted elements
uses hash code of objects when inserted
contains unordered elements
contains unique elements
QQuestion 19. What is the result of this code?
1: class Main {
2: public static void main (String[] args){
3: System.out.println(print(1));
4: }
5: static Exception print(int i){
6: if (i>0) {
7: return new Exception();
8: } else {
9: throw new RuntimeException();
10: }
11: }
12: }
- It will show a stack trace with a runtime exception.
- "java.lang.Exception"
- It will run and throw an exception.
- It will not compile.
Question 20. What is one disadvantage of inheritance?
The internal state of the parent class is accessible to its children.
Overridden methods of the parent class cannot be reused.
Classes related by inheritance are tightly coupled to each other.
Responsibilities are not evenly distributed between parent and child classes.
Question 21. What kind of relationship does extends denote?
is-a
uses-a
has a
was-a
QQuestion 22. Which class can compile given these declarations?
1: interface One {
2: default void method() {
3: System.out.println(""One"");
4: } }
5: interface Two {
6: default void method () {
7: System.out.println(""One"");
8: } }
class Three implements One, Two {
publc void method() {
super.One.method();
} }
class Three implements One, Two {
publc void method() {
One.method();
} }
class Three implements One, Two {
}
class Three implements One, Two {
publc void method() {
One.super.method();
} }
Question 23. What is a problem with this code?
class Main { public static void main(String[] args) { List list = new ArrayList(Arrays.aslist("a", "b","c")); for (String value : list) { if (value.equals("a")) { list.remove(value); System.out.println(list); //outputs [b, c]
ArrayList does not implement the List interface. O
Modifying a collection while iterating through it can throw a ConcurrentModificationException.
Strings should be compared using == instead of equals.
The List interface does not allow an argument of type String to be passed to the remove method.
QQuestion 24. What is the output of this code?
1: class Main {
2: public static void main (String[] args) {
3: List list = new ArrayList();
4: list.add("hello");
5: list.add(2);
6: System.out.print(list.get(0) instanceof Object);
7: System.out.print(list.get(1) instanceof Integer);
8: }
9: }
- The code does not compile.
- truefalse
- truetrue
- falsetrue
Question 25. This code does not compile. What needs to be changed so that it does?
public enum Direction { EAST("E"), WEST("W"), NORTH("N"), SOUTH("S"); private final String shortCode; public String getShortCode() { return shortCode; O
Add a constructor that accepts a String parameter and assigns it to the field shortcode.
Add a setter method for the field shortcode.
Remove the final keyword for the field shortCode.
All enums need to be defined on a single line of code.
Question 26. What does this code print?
String a = "bikini"; String b = new String("bikini"); String c = new String("bikini"); System.out.println(a == b); System.out.println(b == c);
false; true
false; false
true; true
true; false
Question 27. Java Assessment Which OOP concept is this code an example of?
List[] myLists = { new ArrayList<> , new LinkedList<>(), new Stack<> , new Vector<>() for (List list : myLists) { list.clear();
composition
generics
encapsulation
polymorphism
QQuestion 28. Given the following 2 classes, what will be the output of the Main class?
package mypackage;
public class Math {
public static int abs(int num){
return num<0?-num:num;
}
}
package mypackage.elementary;
public class Math {
public static int abs (int num) {
return -num;
}
}
1: import mypackage.Math;
2: import mypackage.elementary.*;
3: class Main {
4: public static void main (String args[]){
5: System.out.println(Math.abs(123));
6: }
7: }
- Lines 1 and 2 generate compiler erros due to class name conflicts.
- "-123"
- It will throw an exception on line 5.
- "123" The answer is "123". The abs() method evaluates to the one inside mypackage.Math class.
Question 29. How do you declare a variable that holds the first four digits of Tr?
decimal pi = 3.141;
double pi = 3.141;
int pi = 3.141;
float pi = 3.141;
Question 30. Which code checks whether the characters in two Strings, named time and money, are the same?
if(time = money){}
if(time.equals(money)){}
if(time == money){}
if(time <> money){}
Question 31. Java Assessment You have a variable of named employees of type List containing multiple entries. The Employee type has a method getName() that returns the employee name. Which statement properly extracts a list of employee names?
employees.stream().collect((e) -> e.getName());
employees.filter (Employee::getName).collect(Collectors.toUnmodifiableList());
employees.stream().map (Employee::getName).collect(Collectors.toList();
employees.collect(employee -> employee.getName();
0 Comments