Java_Project_File
Java_Project_File
Ans2->
public class PrintName {
public static void main(String[] args)
{
String name = "Your Name";
System.out.println("Hello, " + name + "!");
}
}
Q3 Write a program that fine the size of int, float, double and char.
class SizeofdataTypes
{
public static void main(String[] args) {
System.out.println("Size of int: " + (Integer.SIZE / 8) + " bytes.");
System.out.println("Size of long: " + (Long.SIZE / 8) + " bytes.");
System.out.println("Size of char: " + (Character.SIZE / 8) + " bytes.");
System.out.println("Size of float: " + (Float.SIZE / 8) + " bytes.");
System.out.println("Size of double: " + (Double.SIZE / 8) + " bytes.");
}
}
Q4 Write a program that check whether character is vowel or consonant.
Q5 Write a program that find the larger number among three number.
class PrepBytes {
char ch = 'a';
int ascii = ch;
// You can also cast char to int
int castAscii = (int) ch;
}
}
// Time Complexity : O(n)
// Auxiliary Space : O(1)
int i, j;
// n in this case
// printing stars
System.out.print("* ");
System.out.println();
// Driver Function
int n = 5;
printStars(n);
}
}
Q10 Write a program that fine the area of rectangle and triangle by using the two different
function.
}
}
System.out.print("Enter the type of operation you want to perform (+, -, *, /, %): ");
String operation = sc.next();
int result = performOperation(firstNumber, secondNumber, operation);
System.out.println("Your answer is: " + result);
}
class Student {
int id;
String name;
// creating an object of
// Student
System.out.println(s1.id);
System.out.println(s1.name);
}
}
Q13 Write a program that take the student detail and display on the screen by the help of class.
int total=math+eng+phy;
float perc=(float)total/300*100;
}
Q14 Write a program that show the working of Multilevl inheritance.
Ans->class Animal {
class Main {
public static void main(String[] args) {
}
}
import java.sql.*;
class GFG {
String url
String query
Class.forName(
System.out.println(
Statement st = con.createStatement();
ResultSet rs
rs.next();
String name
System.out.println("Connection Closed....");
}
}
Q17 Write a program that function over loading. Create minimum same name 4 function.
return (x + y + z);
return (x + y);
// Driver code
System.out.println(s.sum(10, 20));
System.out.println(s.sum(10.5, 20.5));
}
}
// Base Class
class Complex {
System.out.println(
}
}
// class child extend Demo class
System.out.println(
}
}
// reference
d1.f1();
d2.f1();
}
}
Q19 Write a program for Interface.
Ans->
import java.io.*;
Subject() {
System.out.println("Learning Subject");
void Learn(){
}
}
void syllabus(){
System.out.println("C , Java , C++");
}
}
class GFG {
x.syllabus();
x.Learn();
}
}