Java qanday qismlardan iborat va bu qismlarni tushuntiring? Jdk, jre va jvm lar nima va qanday vazifalarni bajaradi?


Download 32.52 Kb.
bet3/3
Sana14.12.2022
Hajmi32.52 Kb.
#1001156
1   2   3
Bog'liq
var Java

public class Test{
public static void main(String args[]){
int a=10;
int b=20;
System.out.println("a==b"+(a==b));
System.out.println("a!=b"+(a!=b));
System.out.println("a>b"+(a>b));
System.out.println("aSystem.out.println("b>=a"+(b>=a));
System.out.println("b<=a"+(b<=a));
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



public class Test{
public static void main(String args[]){
int a=60; //60=0011 1100
int b=13; //13=0000 1101
int c=0;
c=a&b; //12=0000 1100
System.out.println("a&b="+c);
c=a|b; //61=0011 1101
System.out.println("a|b="+c);
c=a^b; //49=0011 0001
System.out.println("a^b="+c);
c=~a; //-61=1100 0011
System.out.println("~a="+c);
c=a<<2; //240=1111 0000
System.out.println("a<<2="+c);
c=a>>2; //15=1111
System.out.println("a>>2="+c);
c=a>>>2; //15=0000 1111
System.out.println("a>>>2="+c);
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



public class Test{
public static void main(String args[]){
int a=10;
int b=20;
int c=0;
c=a+b;
System.out.println("c=a+b="+c);
c+=a;
System.out.println("c+=a="+c);
c-=a;
System.out.println("c-=a="+c);
c*=a;
System.out.println("c*=a="+c);
a=10;
c=15;
c/=a;
System.out.println("c/=a="+c);
a=10;
c=15;
c%=a;
System.out.println("c%=a="+c);
c<<=2;
System.out.println("c<<=2="+c);
c>>=2;
System.out.println("c>>=2="+c);
c>>=2;
System.out.println("c>>=a="+c);
c&=a;
System.out.println("c&=2="+c);
c^=a;
System.out.println("c^=a="+c);
c|=a;
System.out.println("c|=a="+c);
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



public class Test{
public static void main(String[] args){
int a;
for(a=8; a>0; a--)
System.out.print(a+",");
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



public class Test{
public static void main(String[] args){
int a, b;
for(a=10, b=20; b>a; a++, b--)
System.out.print(a);
}}

  1. Quyidagi kod ektanga nimani chiqaradi?



public class Test{
public static void main(String[] args){
int son[]={1,2,3,4,5};
int summa=0;
for(int i=2; i<5; i++){
summa+=son[i];}
System.out.println("Summa="+summa);
}}



  1. Quyidagi kod ektanga nimani chiqaradi?

public class Test{
public static void main(String[] args){
int d=10;
do{
System.out.println(d);
++d;}
while(d<10);
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



public class Test{
public static void main(String[] args){
int t=10;
metka1:{
metka2:{
System.out.println("Operator 1");
if(t==10)
break metka2;
System.out.println("Operator 2");
System.out.println("Operator 3");}
System.out.println("Operator 4");}
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



public class Test{
public static void main(String[] args){
for(int i=0; i<10; i++) {
System.out.print(i+",");
if(i%2==0) continue;
System.out.println(" ");}
}}



  1. Quyidagi kod ektanga nimani chiqaradi?

public class Test{
public static void main(String[] args){
int a[]=new int[5];//massiv e’lon qilinyapti
a[0]=10;
a[1]=20;
a[2]=70;
a[3]=40;
a[4]=50;
//massivni ekrada chiqarish
for(int i=0;i System.out.print(a[i]+",");
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



class Student{
int yosh;
String ism;
void malumotKirit(int y, String i){
yosh=y;
ism=i;
}
void malumotChiqar(){
System.out.println(yosh+" "+ism);}
public static void main(String args[]){
Student s1=new Student();
Student s2=new Student();
s1.malumotKirit(20,"Rustam");
s2.malumotKirit(22,"Anvar");
s1.malumotChiqar();
s2.malumotChiqar();
}}



  1. Quyidagi kod ektanga nimani chiqaradi?



class kuchuk{
int age;
double weight;
String name;
String color;
}
class Dog{
public static void main(String[] args){
kuchuk Sharik=new kuchuk();
kuchuk Bobik=new kuchuk();
Sharik.age=4;
Sharik.weight=9;
Sharik.name="Sharik";
Sharik.color="qora";
Bobik.age=7;
Bobik.weight=19;
Bobik.name="Bobik";
Bobik.color="oq";
System.out.println("Birinchi kuchuk"+Sharik.age+"yosh");
System.out.println("Ismi"+Sharik.name);
System.out.println("Ogirligi"+Sharik.weight+"kg");
System.out.println("Rangi"+Sharik.color);
System.out.println("----------------------------");
System.out.println("Ikkinchi kuchuk"+Bobik.age+"yosh");
System.out.println("Ismi"+Bobik.name);
System.out.println("Ogirligi"+Bobik.weight+"kg");
System.out.println("Rangi"+Bobik.color);
}}
Download 32.52 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling