Таблица PERSON ID NAME 1 alice 2 john 3 bill 4 mike 5 sara 6 helen 7 steven 8 garry 9 kile 10 liza Таблица PHONE ID PERSON_ID NUMBER [phone] select NAME, NUMBER from PERSON p left join PHONE ph on p.ID=ph.PERSON_ID
Embedded / IoT
What Stream API collectors do you know? What does groupingBy return? How does it differ from toMap? How does toMap behave with duplicate keys?
Is there a constructor in an abstract class?
On which fields should you make hashCode if equals is sufficient?
Question to the interviewer: Is there a synchronization mechanism between the Lucene index and the main SQL storage? How is consistency addressed?
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import java.io.*; @XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(name = "Person", propOrder = { "name", "surname", "address", "phone", }) public class Person implements Serializable, Externalizable { private String name; private String surname; public String address; public String phone; public Person(String name, String surname) { this.name = name; this.surname = surname; } public String getName() { return name; } public String getSurname() { return surname; } @Override public int hashCode() { return 1; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Person person = (Person) o; if (name != null ? !name.equals(person.name) : person.name != null) { return false; } if (surname != null ? !surname.equals(person.surname) : person.surname != null) { return false; } return true; } @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(name); out.writeObject(surname); out.writeObject(phone); out.writeObject(address); } @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { name = (String) in.readObject(); surname = (String) in.readObject(); address = (String) in.readObject(); phone = (String) in.readObject(); } }
// ... call test code here? // ... some code here?
How to get the only element from a List? How to get the only element from a Set if get(0) is not available?
How to execute code after Spring has injected all dependencies of a bean?
What is a lambda expression?
// ... some code here?
How to execute the same code after initialization for all beans implementing a certain interface without duplicating @PostConstruct in each?
Have you worked with the clone() method? Do you like handling CloneNotSupportedException through throw new Error()?
What collection framework interfaces do you know? What common parent do List, Set, Queue, Map have?
hashCode() always returns 1 — what's wrong with this? Will HashMap work correctly?
How to handle invalid messages in Kafka?
What is java.lang.Error? How does it differ from Exception?
// ... some code here? private static List<DocumentProvider> getDocumentProviders() { Reflections reflections = new Reflections(Main.class.getProtectionDomain().getCodeSource().getLocation()); Set<Class<?>> subTypes = reflections.get(SubTypes.of(DocumentProvider.class).asClass()); return subTypes.stream().map(subType -> { try { return (DocumentProvider) subType.getConstructor().newInstance(); } catch (Exception ex) { throw new RuntimeException(ex); } }).collect(Collectors.toList()); }
What is the complexity of the binary search algorithm O?
What is findFirst() and a terminal operation in the Stream API?