0% found this document useful (0 votes)
2 views

ProgrammingTaskSet2

Set of programing tasks

Uploaded by

nvm07947
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

ProgrammingTaskSet2

Set of programing tasks

Uploaded by

nvm07947
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming tasks Set 2

1. Write functions

reverse (int [] table)

whose task is to reverse the order of the input elements

but you cannot create a new table as well as use external libraries and Collections.re-
verse () operation

For example:

As a result of executing the code below, the array should consist of the following ele-
ments {9,8,6,2,1}

int[] table= {1,2,6,8,9}

reverse(table)

2. What will be the result of the code below

class A {

protected void doSmth() {

System.out.println("Do smth A")

protected void doSmthElse() {

System.out.println("Do smth else A")

class B extends A {

protected void doSmth() {

System.out.println("Do smth B")

protected void doSmthElse(int i){

System.out.println("Do smth else B")

}
A ref= new B();

ref.doSmth();

ref.doSmthElse();

3. What will be the result of the code below

String str= "Example A";

str.replace("A","B");

System.out.println(str);

4. For a given list

List<String> list = List.of("John", "James", "Mark","Joanna","Henry");

using java streams

return a list that contains only names beginning with "J"

5. Given a string S, we can split S into 2 strings: S1 and S2. Return the number of ways S can
be split such that the number of unique characters between S1 and S2 are the same.

Example 1:
Input: "aaaa"
Output: 3
Explanation: we can get a - aaa, aa - aa, aaa- a

Example 2:
Input: "bac"
Output: 0

Example 3:
Input: "ababa"
Output: 2
Explanation: ab - aba, aba - ba

You might also like