Java Hyd Team
746 subscribers
986 photos
39 videos
670 files
690 links
https://teamhydteam.my.canva.site/

Can visit us on our website ๐Ÿ˜Š
Still working on it ๐Ÿ˜Š
Download Telegram
public class Q26_1 {
public static void main(String[] args) {
int[]arr = {5,6,8,9,2,4,6,1};
int largest = arr[0];
int secondLargest = arr[0];
System.out.println("The given array is:");
for (int k : arr) {
System.out.print(k + "\t");
}
for (int j : arr) {
if (j > largest) {
secondLargest = largest;
largest = j;
} else if (j > secondLargest) {
secondLargest = j;
}
}
System.out.print("Second largest number is:" + secondLargest);
}
}
public class Q29_1 {
static void printAllSubsets(int[] A, int K) {
int N = A.length;
for (int i = 0; i < (1 << N); i++) {
int sum = 0;
for (int j = 0; j < N; j++) {
if ((i & (1 << j)) > 0)
sum += A[j];
}
if (sum == K) {
for (int j = 0; j < N; j++) {
if ((i & (1 << j)) > 0)
System.out.print(A[j] + " ");
}
System.out.println();
}
}
}
public static void main(String[] args) {
int[] A = {0, 1, 2, 3, 5, 6, 7, 11, 12, 14, 20};
int K = 5;
printAllSubsets(A, K);
}
}
public class Q29_2 {
public static void main(String[] args) {
int[] a = {0, 1, 2, 3, 5, 6, 7, 11, 12, 14, 20};
int n = 5;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length; j++) {
if ((a[i] + a[j]) == n) {
System.out.println("[" + i + "," + j + "]");
}
}
}
}
}
package com.Aman;
public class Q27_1 {
static int maxConsecutiveOnes(int x){
int count = 0;
while (x!=0) {
x = (x & (x << 1));
count++;
}
return count;
}
public static void main(String[] args) {
int x = 10000;
System.out.println(maxConsecutiveOnes(x));
}
}
December 11 ๐Ÿ˜Š๐Ÿ˜Š
Java Hyd Team pinned ยซDecember 11 ๐Ÿ˜Š๐Ÿ˜Šยป
import java.util.Scanner;

public class SwapSmallestLargestElement {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int i, n;

System.out.println("Enter the size of array : ");
n = scanner.nextInt();

int arr[] = new int[n];

System.out.println("Enter the elements to be entered : ");
for(i=0;i<n;i++){
arr[i] = scanner.nextInt();
}

//Call a function Find maximum element of array
int maxElementPos = findMaxElement(arr,n);
System.out.println("The maximum element : "+ arr[maxElementPos]);

//Call a function Find minimum element of array
int minElementPos = findMinElement(arr,n);
System.out.println("The minimum element : "+ arr[minElementPos]);

//Call a function swap maximum and minimum element
swapMaxMinElement(arr, maxElementPos, minElementPos);

// Finally print array after swap
System.out.println("The array after swap is : ");
for(i=0;i<n;i++){
System.out.print(arr[i]+ " ");
}
}

//Find maximum element of array
public static int findMaxElement(int arr[],int n){
int i, pos=0;
int maxVal = arr[0];
for(i=0;i<n;i++){
if(arr[i]>maxVal){
maxVal = arr[i];
pos=i;
}
}
return pos;
}

//Find minimum element of array
public static int findMinElement(int arr[],int n){
int i, pos=0;
int minVal = arr[0];
for(i=0;i<n;i++){
if(arr[i] < minVal){
minVal = arr[i];
pos=i;
}
}
return pos;
}

//Swap maximum and minimum element
public static void swapMaxMinElement(int arr[], int maxElementPos, int minElementPos){

/*To swap max and min numbers, take a temporary variable, and follow the below step,
1) assign maximum number to temporary vaiable.
2) assign minimum number to maximum number.
3) asign temporary vaiable to minimum number*/

int temp;
temp = arr[maxElementPos];
arr[maxElementPos] = arr[minElementPos];
arr[minElementPos] = temp;
}
}
import java.util.Scanner;

public class SwapSmallestLargestElement {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int i, n;

System.out.println("Enter the size of array : ");
n = scanner.nextInt();

int arr[] = new int[n];

System.out.println("Enter the elements to be entered : ");
for(i=0;i<n;i++){
arr[i] = scanner.nextInt();
}

//Call a function Find maximum element of array
int maxElementPos = findMaxElement(arr,n);
System.out.println("The maximum element : "+ arr[maxElementPos]);

//Call a function Find minimum element of array
int minElementPos = findMinElement(arr,n);
System.out.println("The minimum element : "+ arr[minElementPos]);

//Call a function swap maximum and minimum element
swapMaxMinElement(arr, maxElementPos, minElementPos);

// Finally print array after swap
System.out.println("The array after swap is : ");
for(i=0;i<n;i++){
System.out.print(arr[i]+ " ");
}
}

//Find maximum element of array
public static int findMaxElement(int arr[],int n){
int i, pos=0;
int maxVal = arr[0];
for(i=0;i<n;i++){
if(arr[i]>maxVal){
maxVal = arr[i];
pos=i;
}
}
return pos;
}

//Find minimum element of array
public static int findMinElement(int arr[],int n){
int i, pos=0;
int minVal = arr[0];
for(i=0;i<n;i++){
if(arr[i] < minVal){
minVal = arr[i];
pos=i;
}
}
return pos;
}

//Swap maximum and minimum element
public static void swapMaxMinElement(int arr[], int maxElementPos, int minElementPos){

/*To swap max and min numbers, take a temporary variable, and follow the below step,
1) assign maximum number to temporary vaiable.
2) assign minimum number to maximum number.
3) asign temporary vaiable to minimum number*/

int temp;
temp = arr[maxElementPos];
arr[maxElementPos] = arr[minElementPos];
arr[minElementPos] = temp;
}
}
Forwarded from Yakub Sir
Forwarded from SathyaReact
Convert same example to react single page applications
Take all data in form of Strings
public class Main {
public static void main(String[] args) {
int a ;
a= 1;
while(a-->=1){
while(a-->=0){}

}System.out.println(a);
}
}
//****" Special type programs"

public class Main {
public static void main(String[] args) {
int a = 1;
for(a++;a++<=2;a++){
for(a++;a++<=7;a++){
a++;
}
}
System.out.println(a);
}

}
public class Main {
public static void main(String[] args) {
int i=1;
while (i<=20){
if (i>4&&i<17)
continue;
System.out.println (i);
i++;
}
}
}

O/p 1,2,3,4
static char[] swap(String str, int i, int j) {
char[] ch = str.toCharArray();
char temp = ch[i];
ch[i] = ch[j];
ch[j] = temp;
return ch;
}
public static void main(String[] args) {
String s = "aman";System.out.println(swap(s, 0, s.length() - 1));

System.out.println(s);
}
public class RemoveDuplicates {
public static void main(String[] args) {
String str = "sathya";
RemoveDuplicates obj = new RemoveDuplicates();
System.out.println(obj.removeDuplicates(str));
}

public String removeDuplicates(String s) {
char[] chars = s.toCharArray();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < chars.length; i++) {
String str = String.valueOf(chars[i]);
if (!sb.toString().contains(str)) {
sb.append(str);
}
}
return sb.toString();
}
}
๐Ÿ‘2
Q1.)what is framework in java?

A framework in Java is a collection of libraries(jar and war files), APIs, and other components that provide a structure for applications and enable developers to quickly build robust, scalable, and maintainable applications. Java frameworks provide a high-level abstraction layer so that developers can focus on the business logic and not the technical details. Popular Java frameworks include Spring, Hibernate, Struts, and AngularJS.

Q2.)what are the types of frameworks in java
Mainly frameworks are distributed in two types :-
1. Invasive framework
2. Non-Invasive framework

Q3.)difference between invasive and non invasive frameworks in java

Invasive frameworks are those which require developers to modify their existing code to fit the framework's standards in order to use it.
these framework force developer to use , extend or implement

Non-invasive frameworks are those which allow developers to use the framework without making any changes to their existing code. Non-invasive frameworks are typically more modern and easier to use.
these frameworks do not force developer to use , extend or implement


1. Model-View-Controller (MVC)

Model-View-Controller (MVC) is an architectural software design pattern that separates the logic of an application into three interconnected parts: model, view, and controller.

The model is responsible for maintaining data and business logic. It is the core of the application, and it stores and retrieves data.

The view is responsible for presenting the model data to the user. It is the user interface and can be implemented in multiple ways.

The controller is responsible for handling user inputs and updating the model accordingly. It is the bridge between the model and the view.


2. Spring Framework

Spring Framework is an open source application framework and inversion of control container for the Java platform. It provides a comprehensive programming and configuration model for modern Java-based enterprise applications. It was designed to simplify Java EE development and make developers more productive.


3. Struts Framework

The Apache Struts framework is an open-source framework for creating Java web applications. It uses and extends the Java Servlet API to encourage developers to adopt an MVC (Model-View-Controller) architecture. Struts provides a complete framework for creating robust, maintainable, and extensible web applications. It also provides support for internationalization and localization.

4. Hibernate Framework

Hibernate is an open source, object-relational mapping framework for Java. It is designed to provide a simple and efficient way to map Java objects to database tables, and to provide a simple query language for retrieving objects from the database. Hibernate also provides a powerful query language (HQL) for retrieving objects from the database. It is an object-relational mapping tool for the Java programming language. Hibernate is used to map Java classes to database tables and Java data types to SQL data types. It also provides data query and retrieval facilities, including a query language, criteria queries, and native SQL.

5. JavaServer Faces (JSF)
6. Google Web Toolkit (GWT)
7. Apache Wicket


Q4.)what is IOC and IOC lifecycle in spring

Inversion of Control (IoC) is an architectural pattern used in software development. It is also known as Dependency Injection (DI). It is a process in which objects define their dependencies, that is, the other objects they work with, only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. The container then injects those dependencies when it creates the bean.

The IOC container is at the core of the Spring Framework. It is responsible for instantiating, configuring and assembling the objects (beans) that make up the application. The container gets its instructions on what objects to instantiate, configure and