Posts

Quiz

It is possible to employ multiple computer cores to filter a list. Which statement will filter with increased performance? books.parallelStream().filter(book - > { return book.getTitle().startsWith("E"); }).forEach(System.out::println); Correct books.pStream().filter(book - > { return book.getTitle().startsWith("E"); }).forEach(System.out::println); books.streamParallel().filter(book - > { return book.getTitle().startsWith("E"); }).forEach(System.out::println); books.streamp().filter(book - > { return book.getTitle().startsWith("E"); }).forEach(System.out::println); ****************************************************************************************************** Which statement is equivalent to the following code? GreetingMessage gm = new GreetingMessage() { @Override public void greet(String name) { System.out.println("Hello " + name); ...

Java Quize Questions

Q.1 A Queue implements First-In-First-Out(FIFO) data structrure.Which method removes the first element of a list? 1. queue.remove 2. queue.get 3. queue.poll 4. queue.dequeue Ans :- queue.poll Q.2 Collections in Java are an extension of what class? 1.Util 2.Iterable 3.Correct 4.List 5.Interface Ans:- Iterable Q.3 What is a characteristic of an ArrayList? 1.It is faster at removing elements from the middle of a list. 2.It takes up less memory than a linked list. 3.It is harder to implement than a linked list. 4.It is slower at retrieving elements at a particular location. Ans:- It takes up less memory than a linked list. Q.4 What prints to the console after this code executes? LinkedList myList = new LinkedList(); myList.add("A"); myList.add("C"); myList.add(2, "B"); myList.remove("B"); System.out.println(myList); 1. [A, C] 2.[C, A] 3.[A] 4.[C] Ans :- 1. [A, C] Q.5 You create a HashMap data structure using the following stateme...

How to create React project using command prompt?

Image
  How to create React project using command prompt? Ans :- firstly you have to install node js and npm in your system after after that follow these steps:- Step 1:- Open command prompt and for create project write  npx create-next-app Step 2:- Now it will say to write your Project name. Step 3 :- Now write your project name as per your choice. Step 4 :- Now it will ask what is your needs to create a project   Step 5 :- Now you can see dependencies are Installed as shown in below image Step 6 :- Now use this command for change the directory Step 7 :- Now you can see below directory is changed Step 8 :- Now for open the project in Vs code use this command  code . Step 9 :- Now you can see your project is directly opened in Visual Studio Code

Q.we have two tables one is Employee table and another is city table in Employee table we have empId,empName and cityId and in City table we have cityId,cityName and stateName JOIN two tables WHERE empId =100 please write a Query for this.

 Solution :-  SELECT e.empId,           e.empName,           e.cityId,           c.cityName,           c.stateName    FROM Employee e    JOIN City c ON e.cityId = c.cityId    WHERE e.empId =100;

how to create schema and table in mysql workbench ?

Write a simple program to swap the numbers.

 Solution :-  package mv; public class SwapNumber { public static void main(String[] args) { int a=20; int b=30; System.out.println("Before swapping:a:"+a+",b:"+b); int temp=a; a=b; b=temp; System.out.println("After swapping: a:"+a+",b:"+b); } }

What is Intermediate and Terminal Operations ?

 Q. What is Intermediate and Terminal Operations ? Ans:- stream<T> will perform the following  operations:- 1.Intermediate operations 2.Terminal operations 1.Intermediate operations:-  the operations which are performed in b/w streams of objects are known as Intermediate operations. a. filter() b.map() c.sorted() d.distinct() e.peek()  2.Terminal operations:-   the operations which are     performed at the end of stream are known as Terminal operations => The following are some important Terminal operations. a. forEach() b.collect() c.reduce() d.count() e.anyMatch(),allMatch(),noneMatch() f.findAny(),findFirst() ****************************************************************